You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Leet, Ethan C" <et...@lmco.com> on 2003/04/08 18:54:41 UTC

PDFRenderer.


	I am having trouble building pages in PDF.

	I create a StreamRenderer with a PDFRenderer and a FileOutputStream.

	I then create an AreaTree with the StreamRenderer.

	I start the rendering process on the StreamRenderer.

	I then loop three times to create three pages with a SVG on each
page.

	In the Loop, I get a SVGDocument.

	Create an SVGArea and set the SVGDocument.

	I then create a PageMaster and make a Page passing the AreaTree.

	I then call 

	Page.getBody().getMainReferenceArea().addChild(SVGArea);

	I then add the Page to the AreaTree.

	After the Loop I call stoprender() on the StreamRenderer.

	This all works fine and creates a PDF file.

	When I try to view the file I get errors like 

		Illegal operation 'q' inside a text object

	What is this ?

	How do you create multiple PDF pages ?

	??


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: PDFRenderer.

Posted by Jeremias Maerki <de...@greenmail.ch>.
Hmm, the PDF transcoder is only for one-page documents as far as I know.

I wouldn't fiddle with those Area classes. Do it with XSL-FO as Jörg
suggested. Try to come up with an XSL-FO or an XSL-FO generating XSLT
that puts together the layout you need. This will be a lot easier than
trying to make your current approach work.

From what I think you do I'd do it like this:
- Create an XMLReader class (see
  examples/embedding/java/embedding/model/ProjectTeamXMLReader) that
  creates a SAX stream with your SVG documents along these lines:
  
<doc>
  <svgdoc>
    <svg:svg xmlns:svg="http://......
    [..]
    </svg:svg>
  </svgdoc>
  <svgdoc>
    <svg:svg xmlns:svg="http://......
    [..]
    </svg:svg>
  </svgdoc>
</doc>
- Write an XSLT that transforms this XML format to XSL:FO with embedded
  fo:instream-foreign-objects.

Tip:
To convert a DOM to SAX events you can use
org.apache.fop.tools.DocumentReader for example.

Just get back again if you need more help. Good luck!

On 09.04.2003 16:39:02 Leet, Ethan C wrote:
> 
> 	I have used PDF Transcoder for one page.
> 
> 	It works very well.
> 
> 	But what I am trying to do is create mulitple pages from 2D
> graphics.
> 
> 	My test is to create a PDF document with three pages.
> 
> 	For each page I create a SVG Document per page.
> 
> 	Render the SVG document onto the PDF page.
> 
> 	I don't know how to control the pages using the PDF transcoder.
> 
> 	Also since this is for a print service for supporting 2 graphics,
> 
> 	I have to be careful about space, cause the document printing could
> be 50 pages.
> 
> 	Any advice ?
> 
> 	Right now I am still fiddling with the Areas.


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: PDFRenderer.

Posted by Jeremias Maerki <de...@greenmail.ch>.
You just want to convert SVG to PDF? Then it's MUCH easier if you just
used FOP's PDF transcoder. The transcoder is a Batik plug-in that adds
PDF output support. The URL below is an example Java class I recently
added to demonstrate converting SVG to PDF using the PDF transcoder. The
PDF transcoder is included in Batik's current distribution (Version
1.5beta4). Just ask again if you need more help.

http://cvs.apache.org/viewcvs.cgi/xml-fop/examples/embedding/java/embedding/ExampleSVG2PDF.java?rev=1.1&content-type=text/vnd.viewcvs-markup

Also look at this:
http://xml.apache.org/batik/rasterizerTutorial.html
http://xml.apache.org/batik/svgrasterizer.html

On 09.04.2003 14:06:17 Leet, Ethan C wrote:
> 
> 	I am looking for suggestions ?
> 
> 	I build a SVG DOM Tree.
> 
> 	I would need to translate the SVG DOM tree into a FOP DOM tree,
> before I can run FOP right ?
> 
> 	Please, any help would be greatful, I don't want to fiddle with
> anything if I don't need to.
> 
> Thanks
> 
> 
> -----Original Message-----
> From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
> Sent: Tuesday, April 08, 2003 5:41 PM
> To: fop-user@xml.apache.org
> Subject: Re: PDFRenderer.
> 
> 
> Leet, Ethan C wrote:
> > 	Page.getBody().getMainReferenceArea().addChild(SVGArea);
> 
> I highly suspect you'll have to add a block area and probably also a
> line area and ultimately add the SVG to the latter.
> You can check how a working area tree looks like by rendering a simple
> FO file with the SVG first to PDF (to check whether it works) and then
> as XML output.
> 
> BTW why do you fiddle with areas? Building a DOM tree and running
> FOP on it should be much easier.



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: PDFRenderer.

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Leet, Ethan C wrote:
> 	Page.getBody().getMainReferenceArea().addChild(SVGArea);

I highly suspect you'll have to add a block area and probably also a
line area and ultimately add the SVG to the latter.
You can check how a working area tree looks like by rendering a simple
FO file with the SVG first to PDF (to check whether it works) and then
as XML output.

BTW why do you fiddle with areas? Building a DOM tree and running
FOP on it should be much easier.

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org