You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Damien Gallagher <da...@gmail.com> on 2013/01/12 15:30:42 UTC

PDFBox - PDF to SWF

Hi

Just wondering is it possible to convert a PDF to SWF using PDFBox or is
this something thats in the pipeline?

Thanks
Damien

Re: PDFBox - PDF to SWF

Posted by Steve Hannah <st...@weblite.ca>.
Here is the rough code I used:

File out = new File("/tmp/outfile.swf");
VectorGraphics vg = new SWFGraphics2D(out, panel.getSize());

Properties props = new Properties();
props.setProperty("PageSize", "A4");
vg.setProperties(props);
vg.startExport();

// panel is a import org.apache.pdfbox.pdfviewer.PDFPagePanel;
panel.paint(vg);

vg.endExport();

Using the SWFGraphics2D from freehep.

http://java.freehep.org/lib/freehep/api/org/freehep/graphicsio/swf/SWFGraphics2D.html

This used a much older version and I'm not sure if this still works.
In addition it is possible that the SWFGraphics2D doesn't implement
all of the stuff that is used (might have some blank implementations)
so you'll have to test and see if it works for yourself.  In any case
the same strategy should work for any SWF library that provides a
Java2D graphics context.

-Steve

On Sun, Jan 13, 2013 at 1:08 PM, Damien Gallagher
<da...@gmail.com> wrote:
> Hi Steve
>
> Sorry last question
> When you did this in the past, did you override some of the classes within
> PDFBox or did you extend PDFBox and keep your own version of the code?
>
> Thanks
> Damien
>
> On Sun, Jan 13, 2013 at 8:20 PM, Damien Gallagher <
> damien.gallagher@gmail.com> wrote:
>
>> thats great to know, ill have a look into this Steve
>> Thanks for your help
>>
>>
>> On Sun, Jan 13, 2013 at 8:17 PM, Steve Hannah <st...@weblite.ca> wrote:
>>
>>> One more thing, as I didn't really state explicitly what I meant by
>>> "hook in".  PDFBox provides you with the ability to write a PDF page
>>> as an image.  If you take an SWF graphics context (i.e. a subclass of
>>> java.awt.Graphics that is set to write SWF) from one of those SWF
>>> libraries, you should be able to pass that straight into the paint()
>>> method (where pdfbox renders the page) and it should just work.  I did
>>> something like this with pdfbox a long time ago...
>>>
>>> -Steve
>>>
>>> On Sun, Jan 13, 2013 at 11:55 AM, Damien Gallagher
>>> <da...@gmail.com> wrote:
>>> > Thanks Steve
>>> >
>>> > there is plenty listed in that stackoverflow conversation that will
>>> help me
>>> > when it comes to converting to swf
>>> >
>>> > Thanks for your help
>>> > Damien
>>> >
>>> > On Sat, Jan 12, 2013 at 4:56 PM, Steve Hannah <st...@weblite.ca> wrote:
>>> >
>>> >> I don't think PDFBox does this, but you could easily hook it up to any
>>> >> of the SWF Java2D implementations out there.   This stack overflow
>>> >> thread discusses a few:
>>> >> http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash
>>> >>
>>> >> Several years ago I also used the freehep vector graphics libraries to
>>> >> write SWF using Java2D, and it worked quite well.  I don't see that
>>> >> library mentioned in the stack overflow thread:
>>> >> http://java.freehep.org/#vectorgraphics
>>> >>
>>> >> -Steve
>>> >>
>>> >> On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
>>> >> <da...@gmail.com> wrote:
>>> >> > Hi
>>> >> >
>>> >> > Just wondering is it possible to convert a PDF to SWF using PDFBox
>>> or is
>>> >> > this something thats in the pipeline?
>>> >> >
>>> >> > Thanks
>>> >> > Damien
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Steve Hannah
>>> >> Web Lite Solutions Corp.
>>> >>
>>>
>>>
>>>
>>> --
>>> Steve Hannah
>>> Web Lite Solutions Corp.
>>>
>>
>>



-- 
Steve Hannah
Web Lite Solutions Corp.

Re: PDFBox - PDF to SWF

Posted by Damien Gallagher <da...@gmail.com>.
Hi Steve

Sorry last question
When you did this in the past, did you override some of the classes within
PDFBox or did you extend PDFBox and keep your own version of the code?

Thanks
Damien

On Sun, Jan 13, 2013 at 8:20 PM, Damien Gallagher <
damien.gallagher@gmail.com> wrote:

> thats great to know, ill have a look into this Steve
> Thanks for your help
>
>
> On Sun, Jan 13, 2013 at 8:17 PM, Steve Hannah <st...@weblite.ca> wrote:
>
>> One more thing, as I didn't really state explicitly what I meant by
>> "hook in".  PDFBox provides you with the ability to write a PDF page
>> as an image.  If you take an SWF graphics context (i.e. a subclass of
>> java.awt.Graphics that is set to write SWF) from one of those SWF
>> libraries, you should be able to pass that straight into the paint()
>> method (where pdfbox renders the page) and it should just work.  I did
>> something like this with pdfbox a long time ago...
>>
>> -Steve
>>
>> On Sun, Jan 13, 2013 at 11:55 AM, Damien Gallagher
>> <da...@gmail.com> wrote:
>> > Thanks Steve
>> >
>> > there is plenty listed in that stackoverflow conversation that will
>> help me
>> > when it comes to converting to swf
>> >
>> > Thanks for your help
>> > Damien
>> >
>> > On Sat, Jan 12, 2013 at 4:56 PM, Steve Hannah <st...@weblite.ca> wrote:
>> >
>> >> I don't think PDFBox does this, but you could easily hook it up to any
>> >> of the SWF Java2D implementations out there.   This stack overflow
>> >> thread discusses a few:
>> >> http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash
>> >>
>> >> Several years ago I also used the freehep vector graphics libraries to
>> >> write SWF using Java2D, and it worked quite well.  I don't see that
>> >> library mentioned in the stack overflow thread:
>> >> http://java.freehep.org/#vectorgraphics
>> >>
>> >> -Steve
>> >>
>> >> On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
>> >> <da...@gmail.com> wrote:
>> >> > Hi
>> >> >
>> >> > Just wondering is it possible to convert a PDF to SWF using PDFBox
>> or is
>> >> > this something thats in the pipeline?
>> >> >
>> >> > Thanks
>> >> > Damien
>> >>
>> >>
>> >>
>> >> --
>> >> Steve Hannah
>> >> Web Lite Solutions Corp.
>> >>
>>
>>
>>
>> --
>> Steve Hannah
>> Web Lite Solutions Corp.
>>
>
>

Re: PDFBox - PDF to SWF

Posted by Damien Gallagher <da...@gmail.com>.
thats great to know, ill have a look into this Steve
Thanks for your help

On Sun, Jan 13, 2013 at 8:17 PM, Steve Hannah <st...@weblite.ca> wrote:

> One more thing, as I didn't really state explicitly what I meant by
> "hook in".  PDFBox provides you with the ability to write a PDF page
> as an image.  If you take an SWF graphics context (i.e. a subclass of
> java.awt.Graphics that is set to write SWF) from one of those SWF
> libraries, you should be able to pass that straight into the paint()
> method (where pdfbox renders the page) and it should just work.  I did
> something like this with pdfbox a long time ago...
>
> -Steve
>
> On Sun, Jan 13, 2013 at 11:55 AM, Damien Gallagher
> <da...@gmail.com> wrote:
> > Thanks Steve
> >
> > there is plenty listed in that stackoverflow conversation that will help
> me
> > when it comes to converting to swf
> >
> > Thanks for your help
> > Damien
> >
> > On Sat, Jan 12, 2013 at 4:56 PM, Steve Hannah <st...@weblite.ca> wrote:
> >
> >> I don't think PDFBox does this, but you could easily hook it up to any
> >> of the SWF Java2D implementations out there.   This stack overflow
> >> thread discusses a few:
> >> http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash
> >>
> >> Several years ago I also used the freehep vector graphics libraries to
> >> write SWF using Java2D, and it worked quite well.  I don't see that
> >> library mentioned in the stack overflow thread:
> >> http://java.freehep.org/#vectorgraphics
> >>
> >> -Steve
> >>
> >> On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
> >> <da...@gmail.com> wrote:
> >> > Hi
> >> >
> >> > Just wondering is it possible to convert a PDF to SWF using PDFBox or
> is
> >> > this something thats in the pipeline?
> >> >
> >> > Thanks
> >> > Damien
> >>
> >>
> >>
> >> --
> >> Steve Hannah
> >> Web Lite Solutions Corp.
> >>
>
>
>
> --
> Steve Hannah
> Web Lite Solutions Corp.
>

Re: PDFBox - PDF to SWF

Posted by Steve Hannah <st...@weblite.ca>.
One more thing, as I didn't really state explicitly what I meant by
"hook in".  PDFBox provides you with the ability to write a PDF page
as an image.  If you take an SWF graphics context (i.e. a subclass of
java.awt.Graphics that is set to write SWF) from one of those SWF
libraries, you should be able to pass that straight into the paint()
method (where pdfbox renders the page) and it should just work.  I did
something like this with pdfbox a long time ago...

-Steve

On Sun, Jan 13, 2013 at 11:55 AM, Damien Gallagher
<da...@gmail.com> wrote:
> Thanks Steve
>
> there is plenty listed in that stackoverflow conversation that will help me
> when it comes to converting to swf
>
> Thanks for your help
> Damien
>
> On Sat, Jan 12, 2013 at 4:56 PM, Steve Hannah <st...@weblite.ca> wrote:
>
>> I don't think PDFBox does this, but you could easily hook it up to any
>> of the SWF Java2D implementations out there.   This stack overflow
>> thread discusses a few:
>> http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash
>>
>> Several years ago I also used the freehep vector graphics libraries to
>> write SWF using Java2D, and it worked quite well.  I don't see that
>> library mentioned in the stack overflow thread:
>> http://java.freehep.org/#vectorgraphics
>>
>> -Steve
>>
>> On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
>> <da...@gmail.com> wrote:
>> > Hi
>> >
>> > Just wondering is it possible to convert a PDF to SWF using PDFBox or is
>> > this something thats in the pipeline?
>> >
>> > Thanks
>> > Damien
>>
>>
>>
>> --
>> Steve Hannah
>> Web Lite Solutions Corp.
>>



-- 
Steve Hannah
Web Lite Solutions Corp.

Re: PDFBox - PDF to SWF

Posted by Damien Gallagher <da...@gmail.com>.
Thanks Steve

there is plenty listed in that stackoverflow conversation that will help me
when it comes to converting to swf

Thanks for your help
Damien

On Sat, Jan 12, 2013 at 4:56 PM, Steve Hannah <st...@weblite.ca> wrote:

> I don't think PDFBox does this, but you could easily hook it up to any
> of the SWF Java2D implementations out there.   This stack overflow
> thread discusses a few:
> http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash
>
> Several years ago I also used the freehep vector graphics libraries to
> write SWF using Java2D, and it worked quite well.  I don't see that
> library mentioned in the stack overflow thread:
> http://java.freehep.org/#vectorgraphics
>
> -Steve
>
> On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
> <da...@gmail.com> wrote:
> > Hi
> >
> > Just wondering is it possible to convert a PDF to SWF using PDFBox or is
> > this something thats in the pipeline?
> >
> > Thanks
> > Damien
>
>
>
> --
> Steve Hannah
> Web Lite Solutions Corp.
>

Re: PDFBox - PDF to SWF

Posted by Steve Hannah <st...@weblite.ca>.
I don't think PDFBox does this, but you could easily hook it up to any
of the SWF Java2D implementations out there.   This stack overflow
thread discusses a few:
http://stackoverflow.com/questions/267001/save-java2d-to-swf-flash

Several years ago I also used the freehep vector graphics libraries to
write SWF using Java2D, and it worked quite well.  I don't see that
library mentioned in the stack overflow thread:
http://java.freehep.org/#vectorgraphics

-Steve

On Sat, Jan 12, 2013 at 6:32 AM, Damien Gallagher
<da...@gmail.com> wrote:
> Hi
>
> Just wondering is it possible to convert a PDF to SWF using PDFBox or is
> this something thats in the pipeline?
>
> Thanks
> Damien



-- 
Steve Hannah
Web Lite Solutions Corp.

PDFBox - PDF to SWF

Posted by Damien Gallagher <da...@gmail.com>.
Hi

Just wondering is it possible to convert a PDF to SWF using PDFBox or is
this something thats in the pipeline?

Thanks
Damien