You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Bill Gamble <ga...@gmail.com> on 2008/08/06 22:11:10 UTC

Graphics2D to PDF

Hello Everyone,

 

I am new to Apache XML Graphics projects and I was wondering if someone
could answer a few questions for me or point me in the right direction where
I can find them myself.

 

What I am trying to accomplish: I am trying to use a Graphics2D object to
draw to a multi page PDF document. 

 

I have read through the descriptions of Batik, FOP, and the Graphics Commons
project, and look through the available documentation and code samples and
here is what I gathered so far:

 

1)    I will need to draw out to an SVG file (in my case, multiple SVG
files) with Batik.

2)    Use FOP to read in the SVG files and write them to PDF.

 

Is this correct? I was intrigued by the Graphics Commons overview which
stated it provides "Graphics2D implementations that let you generate PDF &
PostScript files, and much more." and got me all excited, however I was not
able to find any documentation, examples, etc on how to do this. I googled
it for a while but was not able to come up with anything relevant.

 

If anyone can:

 

1)    Confirm or correct the statements about the best approach to producing
a multipage PDF document.

2)    Point me to any documentation, javadocs, etc. I am probably missing
something but have not been able to find much documentation at all.

 

Thank you,

Bill Gamble

 

LabPrints

130 Remsen St.

Cohoes, NY 12047

1-518-274-3931

 


RE: Graphics2D to PDF

Posted by Bill Gamble <ga...@gmail.com>.
Hi Jeremias,

I just wanted to say thanks again for your reply. As I reread your first
email I saw your note that I was posting to the wrong mailing list, so I
didn't want to send anything else there. I did want to say that shortly
after I had sent my second email I had found a post where you had given
someone an example of and FO file that used the include for an external
document, which was exactly what I was looking for. 

It took a day or so of going through the fo examples to getting a better
understanding of the syntax, but now that I'm staring to get it I see the
enormous capabilities of FOP; kick ass!

I'm going to be using some basic formatting with the external-document, and
can't want to use more of its capabilities as it evolves.

Thanks again, and hopefully at some point in the future I may even be able
to contribute to the project myself.

Bill Gamble

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Thursday, August 07, 2008 2:17 AM
To: batik-dev@xmlgraphics.apache.org
Subject: Re: Graphics2D to PDF

Bill,

you can take a look at
https://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/
cli/image2fo.xsl?revision=611278
which I use for FOP's -imagein command-line parameter. Internally, I
generate an XML that looks like this:

<image>http://myhost/myimage.png</image>

You can easily extend this a little to include multiple images with some
minimal XSLT knowledge. You can also just generate the FO directly if
it's such a simple case. HTH

On 06.08.2008 23:02:08 Bill Gamble wrote:
> Hello Jeremias,
> 
> Thank you very much for your reply.
> 
> You are correct; I am trying to convert multiple svgs to one pdf. I read
> through the FOP extensions documentation and it seems to make sense to me.
> It's going to take a little while for some of this stuff to click with me
> (logically). Are there any example XML/FO, and stylesheets out there that
I
> can take a look at that you know of?
> 
> Thanks much!
> Bill Gamble
> 
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Sent: Wednesday, August 06, 2008 4:26 PM
> To: batik-dev@xmlgraphics.apache.org
> Subject: Re: Graphics2D to PDF
> 
> On 06.08.2008 22:11:10 Bill Gamble wrote:
> > Hello Everyone,
> > 
> >  
> > 
> > I am new to Apache XML Graphics projects and I was wondering if someone
> > could answer a few questions for me or point me in the right direction
> where
> > I can find them myself.
> > 
> >  
> > 
> > What I am trying to accomplish: I am trying to use a Graphics2D object
to
> > draw to a multi page PDF document. 
> > 
> >  
> > 
> > I have read through the descriptions of Batik, FOP, and the Graphics
> Commons
> > project, and look through the available documentation and code samples
and
> > here is what I gathered so far:
> > 
> >  
> > 
> > 1)    I will need to draw out to an SVG file (in my case, multiple SVG
> > files) with Batik.
> >
> > 2)    Use FOP to read in the SVG files and write them to PDF.
> 
> If I understand you correctly, you need to convert multiple SVGs to one
> PDF, right? In that case, I'd recommend using FOP with the
> fox:external-document extension (one such element per SVG):
> http://xmlgraphics.apache.org/fop/0.95/extensions.html#external-document
> Obviously, that requires a minimal FO file that sticks the SVGs together.
> That can easily be generated from a minimal XML file with the filenames
> and a stylesheet that generates the necessary FO tags.
> 
> If it's about converting only one SVG to PDF you can use the above or
> you can use the PDFTranscoder (which unfortunately is still in FOP
> although it's long been decided it should move. Just hasn't happened,
> yet). http://xmlgraphics.apache.org/batik/using/transcoder.html
> >  
> > 
> > Is this correct? I was intrigued by the Graphics Commons overview which
> > stated it provides "Graphics2D implementations that let you generate PDF
&
> > PostScript files, and much more." and got me all excited, however I was
> not
> > able to find any documentation, examples, etc on how to do this. I
googled
> > it for a while but was not able to come up with anything relevant.
> 
> Hmm, some of that description still only is about our dreams. Reality is
> a bit behind still. ;-) There's a Graphics2D implementation there, but
> the PDFDocumentGraphics2D class is still in FOP. It's still on my list
> to move it....I'm hoping for more free time and energy. ;-)
> 
> But I don't recommend interfacing directly with PDFDocumentGraphics2D if
> you need to process SVG. It's probably much easier to use a higher-level
> API like the Batik Transcoder API or the FOP API.
> 
> >  
> > 
> > If anyone can:
> > 
> >  
> > 
> > 1)    Confirm or correct the statements about the best approach to
> producing
> > a multipage PDF document.
> 
> See above.
> 
> > 2)    Point me to any documentation, javadocs, etc. I am probably
missing
> > something but have not been able to find much documentation at all.
> 
> Javadocs can be produced for all of Batik, FOP and Commons. I hope that
> above tips help you. Otherwise, please ping me again.
> 
> Please post questions to the user list next time. Thanks!
> 
> 
> 
> Jeremias Maerki



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Graphics2D to PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Bill,

you can take a look at
https://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/image2fo.xsl?revision=611278
which I use for FOP's -imagein command-line parameter. Internally, I
generate an XML that looks like this:

<image>http://myhost/myimage.png</image>

You can easily extend this a little to include multiple images with some
minimal XSLT knowledge. You can also just generate the FO directly if
it's such a simple case. HTH

On 06.08.2008 23:02:08 Bill Gamble wrote:
> Hello Jeremias,
> 
> Thank you very much for your reply.
> 
> You are correct; I am trying to convert multiple svgs to one pdf. I read
> through the FOP extensions documentation and it seems to make sense to me.
> It's going to take a little while for some of this stuff to click with me
> (logically). Are there any example XML/FO, and stylesheets out there that I
> can take a look at that you know of?
> 
> Thanks much!
> Bill Gamble
> 
> 
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
> Sent: Wednesday, August 06, 2008 4:26 PM
> To: batik-dev@xmlgraphics.apache.org
> Subject: Re: Graphics2D to PDF
> 
> On 06.08.2008 22:11:10 Bill Gamble wrote:
> > Hello Everyone,
> > 
> >  
> > 
> > I am new to Apache XML Graphics projects and I was wondering if someone
> > could answer a few questions for me or point me in the right direction
> where
> > I can find them myself.
> > 
> >  
> > 
> > What I am trying to accomplish: I am trying to use a Graphics2D object to
> > draw to a multi page PDF document. 
> > 
> >  
> > 
> > I have read through the descriptions of Batik, FOP, and the Graphics
> Commons
> > project, and look through the available documentation and code samples and
> > here is what I gathered so far:
> > 
> >  
> > 
> > 1)    I will need to draw out to an SVG file (in my case, multiple SVG
> > files) with Batik.
> >
> > 2)    Use FOP to read in the SVG files and write them to PDF.
> 
> If I understand you correctly, you need to convert multiple SVGs to one
> PDF, right? In that case, I'd recommend using FOP with the
> fox:external-document extension (one such element per SVG):
> http://xmlgraphics.apache.org/fop/0.95/extensions.html#external-document
> Obviously, that requires a minimal FO file that sticks the SVGs together.
> That can easily be generated from a minimal XML file with the filenames
> and a stylesheet that generates the necessary FO tags.
> 
> If it's about converting only one SVG to PDF you can use the above or
> you can use the PDFTranscoder (which unfortunately is still in FOP
> although it's long been decided it should move. Just hasn't happened,
> yet). http://xmlgraphics.apache.org/batik/using/transcoder.html
> >  
> > 
> > Is this correct? I was intrigued by the Graphics Commons overview which
> > stated it provides "Graphics2D implementations that let you generate PDF &
> > PostScript files, and much more." and got me all excited, however I was
> not
> > able to find any documentation, examples, etc on how to do this. I googled
> > it for a while but was not able to come up with anything relevant.
> 
> Hmm, some of that description still only is about our dreams. Reality is
> a bit behind still. ;-) There's a Graphics2D implementation there, but
> the PDFDocumentGraphics2D class is still in FOP. It's still on my list
> to move it....I'm hoping for more free time and energy. ;-)
> 
> But I don't recommend interfacing directly with PDFDocumentGraphics2D if
> you need to process SVG. It's probably much easier to use a higher-level
> API like the Batik Transcoder API or the FOP API.
> 
> >  
> > 
> > If anyone can:
> > 
> >  
> > 
> > 1)    Confirm or correct the statements about the best approach to
> producing
> > a multipage PDF document.
> 
> See above.
> 
> > 2)    Point me to any documentation, javadocs, etc. I am probably missing
> > something but have not been able to find much documentation at all.
> 
> Javadocs can be produced for all of Batik, FOP and Commons. I hope that
> above tips help you. Otherwise, please ping me again.
> 
> Please post questions to the user list next time. Thanks!
> 
> 
> 
> Jeremias Maerki



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


RE: Graphics2D to PDF

Posted by Bill Gamble <ga...@gmail.com>.
Hello Jeremias,

Thank you very much for your reply.

You are correct; I am trying to convert multiple svgs to one pdf. I read
through the FOP extensions documentation and it seems to make sense to me.
It's going to take a little while for some of this stuff to click with me
(logically). Are there any example XML/FO, and stylesheets out there that I
can take a look at that you know of?

Thanks much!
Bill Gamble


-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Wednesday, August 06, 2008 4:26 PM
To: batik-dev@xmlgraphics.apache.org
Subject: Re: Graphics2D to PDF

On 06.08.2008 22:11:10 Bill Gamble wrote:
> Hello Everyone,
> 
>  
> 
> I am new to Apache XML Graphics projects and I was wondering if someone
> could answer a few questions for me or point me in the right direction
where
> I can find them myself.
> 
>  
> 
> What I am trying to accomplish: I am trying to use a Graphics2D object to
> draw to a multi page PDF document. 
> 
>  
> 
> I have read through the descriptions of Batik, FOP, and the Graphics
Commons
> project, and look through the available documentation and code samples and
> here is what I gathered so far:
> 
>  
> 
> 1)    I will need to draw out to an SVG file (in my case, multiple SVG
> files) with Batik.
>
> 2)    Use FOP to read in the SVG files and write them to PDF.

If I understand you correctly, you need to convert multiple SVGs to one
PDF, right? In that case, I'd recommend using FOP with the
fox:external-document extension (one such element per SVG):
http://xmlgraphics.apache.org/fop/0.95/extensions.html#external-document
Obviously, that requires a minimal FO file that sticks the SVGs together.
That can easily be generated from a minimal XML file with the filenames
and a stylesheet that generates the necessary FO tags.

If it's about converting only one SVG to PDF you can use the above or
you can use the PDFTranscoder (which unfortunately is still in FOP
although it's long been decided it should move. Just hasn't happened,
yet). http://xmlgraphics.apache.org/batik/using/transcoder.html
>  
> 
> Is this correct? I was intrigued by the Graphics Commons overview which
> stated it provides "Graphics2D implementations that let you generate PDF &
> PostScript files, and much more." and got me all excited, however I was
not
> able to find any documentation, examples, etc on how to do this. I googled
> it for a while but was not able to come up with anything relevant.

Hmm, some of that description still only is about our dreams. Reality is
a bit behind still. ;-) There's a Graphics2D implementation there, but
the PDFDocumentGraphics2D class is still in FOP. It's still on my list
to move it....I'm hoping for more free time and energy. ;-)

But I don't recommend interfacing directly with PDFDocumentGraphics2D if
you need to process SVG. It's probably much easier to use a higher-level
API like the Batik Transcoder API or the FOP API.

>  
> 
> If anyone can:
> 
>  
> 
> 1)    Confirm or correct the statements about the best approach to
producing
> a multipage PDF document.

See above.

> 2)    Point me to any documentation, javadocs, etc. I am probably missing
> something but have not been able to find much documentation at all.

Javadocs can be produced for all of Batik, FOP and Commons. I hope that
above tips help you. Otherwise, please ping me again.

Please post questions to the user list next time. Thanks!



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Graphics2D to PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 06.08.2008 22:11:10 Bill Gamble wrote:
> Hello Everyone,
> 
>  
> 
> I am new to Apache XML Graphics projects and I was wondering if someone
> could answer a few questions for me or point me in the right direction where
> I can find them myself.
> 
>  
> 
> What I am trying to accomplish: I am trying to use a Graphics2D object to
> draw to a multi page PDF document. 
> 
>  
> 
> I have read through the descriptions of Batik, FOP, and the Graphics Commons
> project, and look through the available documentation and code samples and
> here is what I gathered so far:
> 
>  
> 
> 1)    I will need to draw out to an SVG file (in my case, multiple SVG
> files) with Batik.
>
> 2)    Use FOP to read in the SVG files and write them to PDF.

If I understand you correctly, you need to convert multiple SVGs to one
PDF, right? In that case, I'd recommend using FOP with the
fox:external-document extension (one such element per SVG):
http://xmlgraphics.apache.org/fop/0.95/extensions.html#external-document
Obviously, that requires a minimal FO file that sticks the SVGs together.
That can easily be generated from a minimal XML file with the filenames
and a stylesheet that generates the necessary FO tags.

If it's about converting only one SVG to PDF you can use the above or
you can use the PDFTranscoder (which unfortunately is still in FOP
although it's long been decided it should move. Just hasn't happened,
yet). http://xmlgraphics.apache.org/batik/using/transcoder.html
>  
> 
> Is this correct? I was intrigued by the Graphics Commons overview which
> stated it provides "Graphics2D implementations that let you generate PDF &
> PostScript files, and much more." and got me all excited, however I was not
> able to find any documentation, examples, etc on how to do this. I googled
> it for a while but was not able to come up with anything relevant.

Hmm, some of that description still only is about our dreams. Reality is
a bit behind still. ;-) There's a Graphics2D implementation there, but
the PDFDocumentGraphics2D class is still in FOP. It's still on my list
to move it....I'm hoping for more free time and energy. ;-)

But I don't recommend interfacing directly with PDFDocumentGraphics2D if
you need to process SVG. It's probably much easier to use a higher-level
API like the Batik Transcoder API or the FOP API.

>  
> 
> If anyone can:
> 
>  
> 
> 1)    Confirm or correct the statements about the best approach to producing
> a multipage PDF document.

See above.

> 2)    Point me to any documentation, javadocs, etc. I am probably missing
> something but have not been able to find much documentation at all.

Javadocs can be produced for all of Batik, FOP and Commons. I hope that
above tips help you. Otherwise, please ping me again.

Please post questions to the user list next time. Thanks!



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org