You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Ron Ben-Natan <ro...@guardium.com> on 2003/12/16 20:27:02 UTC
Subject: How to get ALL parts of a large SVG document in a single PDF page
Hi,
I am posting this question to both the Batik group and the FOP group -
not sure who might be able to help me.
I am running into a problem when trying to transcode SVG content to PDF.
I have quite a large SVG document which is created using JGraph.
It usually has a width of 1100 pixels and a height of 1600 pixels.
When viewed as SVG everything is great.
I then use the PDFTranscoder to create a PDF document.
The problem is that it is "clipped" - I see only a small segment of the
document in teh top left corner.
I have tried in vain to get the entire document converted.
Any help would be greatly appreciated.
Here is how things are created in my code:
The SVG is created by using a JGraph object and then painting onto an
SVG canvas:
DOMImplementation domImpl =
SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document document = domImpl.createDocument(svgNS, "svg",
null);
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
aGraph.paint(svgGenerator);
Then I dump it into a file which is used to generate the PDF output:
(The transcoder is PDFTranscoder)
XMLAbstractTranscoder t =
(XMLAbstractTranscoder)((Class)transcoderMap.get(contentType)).newInstan
ce();
java.awt.Rectangle aoi = new java.awt.Rectangle(0, 0, (new
Double(dim.getWidth())).intValue(), (new
Double(dim.getHeight())).intValue());
t.addTranscodingHint(SVGAbstractTranscoder.KEY_AOI, aoi);
t.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH,
new Float(dim.getWidth()));
t.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT,
new Float(dim.getHeight()));
TranscoderInput input = new TranscoderInput(svgURI);
TranscoderOutput output = new TranscoderOutput(pdfStream);
t.transcode(input, output);
I tried with and without hints, with and without height and width in the
SCG doc, tried to
play with pixel to MM mapping (which doesn't seem to do anything as far
as I can see) and all
kinds of other attempts but I have reached the point that because I
don't understand what
is doing the clipping, it is all voodoo for me at this point.
By the way - if I can get a PDF document with multiple pages in it that
would be even better!!
Thanks for the help,
-Ron
Re: Subject: How to get ALL parts of a large SVG document in a single
PDF page
Posted by Thomas DeWeese <Th...@Kodak.com>.
Ron Ben-Natan wrote:
> I am posting this question to both the Batik group and the FOP group -
> not sure who might be able to help me.
> I am running into a problem when trying to transcode SVG content to PDF.
> I have quite a large SVG document which is created using JGraph.
> It usually has a width of 1100 pixels and a height of 1600 pixels.
> When viewed as SVG everything is great.
You need to set the viewBox attribute on the outermost SVG element.
This will tell the transcoder what part of the infinite canvas should
be scaled to the output device.
If this doesn't work you might try CVS as I have fixed some bugs in
this general area since the last release.
> By the way - if I can get a PDF document with multiple pages in it that
> would be even better!!
To do this you need to create an FO document that embeds SVG.
You can then use the SVG 'image' element to reference the complete
document and attach an svg 'view' fragment to the end of the URL
to control what portion of the entire document get's rendered:
foo.svg#svgView(viewBox(0,0,1100,1600))
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org