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 Benjamin Diedrichsen <b....@googlemail.com> on 2011/02/02 13:16:07 UTC

SVG 1.2 support and PDF generation

Hi all,

I am currently using batik and pdftranscoder.jar to transform svg documents
into pdf. Recently I tried the new text flowing features of SVG 1.2 and was
pretty disappointed by the results. It seems that the flowRegion ant
flowPara elements and so forth are silently ignored. At least the output is
very different to what I would expect. On
http://xmlgraphics.apache.org/batik/dev/svg12.html I read the SVG 1.2 should
be supported in the branch. I compiled the latest trunk and use it to
transform the SVG but the text just doesn't get rendered and the flowRegion
is always shown as a black box.

>From what I've read in the mailing lists and on the batik webpage, the text
flowing features are supported or at least should be. So, what am I doing
wrong here?

Here is a very simple example that I actually took from the w3c page and
that I am working with.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.2//EN" "
http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xml="
http://www.w3.org/XML/1998/namespace"
width="742.6771734" height="969.4488284" version="1.2" xml:space="preserve">
  <title>Basic textflow</title>
  <rect x="0" y="0" width="100%" height="100%" fill="yellow"/>
  <flowRoot font-size="16">
    <flowRegion>
      <path d="M100,50L50,300L250,300L300,50z"
style="background-color:#111111" fill="#111111"/>
    </flowRegion>
      <flowPara>Tomorrow, and tomorrow, and tomorrow; creeps in this
       petty pace from day to day, until the last syllable of recorded time.

       And all our yesterdays have lighted fools the way to dusty death.
     </flowPara>
  </flowRoot>
  <path d="M90,40L40,270L260,270L210,40z" fill="none" stroke="black"
stroke-width="5"/>
</svg>

Anybody manages to transform this to pdf with proper text layout? Any
comments on the current status of the SVG 1.2 support?

Here is part of my java code:

Reader domReader = DOMUtilities.createXMLDocumentReader(is);

        SAXSVGDocumentFactory saxDocFactory = new SAXSVGDocumentFactory(
                "org.apache.xerces.parsers.SAXParser");
        SVGDocument svgDocument = saxDocFactory.createSVGDocument(null,
domReader);


PDFTranscoder pdfTranscoder = new PDFTranscoder();
                    TranscoderInput tInput = new
TranscoderInput(svgDocument);
                    TranscoderOutput tOutput = new
TranscoderOutput(tmpBout);

                    pdfTranscoder.transcode(tInput, tOutput);

Any help and comments will be rewarded with pure gratefulness. Regards,
Benni

Re: SVG 1.2 support and PDF generation

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Benjamin,
try putting the flowPara into a flowDiv.

PS: please don't cross-post between batik-users and batik-dev. All Batik
devs are also here on batik-users.

On 02.02.2011 13:16:07 Benjamin Diedrichsen wrote:
> Hi all,
> 
> I am currently using batik and pdftranscoder.jar to transform svg documents
> into pdf. Recently I tried the new text flowing features of SVG 1.2 and was
> pretty disappointed by the results. It seems that the flowRegion ant
> flowPara elements and so forth are silently ignored. At least the output is
> very different to what I would expect. On
> http://xmlgraphics.apache.org/batik/dev/svg12.html I read the SVG 1.2 should
> be supported in the branch. I compiled the latest trunk and use it to
> transform the SVG but the text just doesn't get rendered and the flowRegion
> is always shown as a black box.
> 
> From what I've read in the mailing lists and on the batik webpage, the text
> flowing features are supported or at least should be. So, what am I doing
> wrong here?
> 
> Here is a very simple example that I actually took from the w3c page and
> that I am working with.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.2//EN" "
> http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xml="
> http://www.w3.org/XML/1998/namespace"
> width="742.6771734" height="969.4488284" version="1.2" xml:space="preserve">
>   <title>Basic textflow</title>
>   <rect x="0" y="0" width="100%" height="100%" fill="yellow"/>
>   <flowRoot font-size="16">
>     <flowRegion>
>       <path d="M100,50L50,300L250,300L300,50z"
> style="background-color:#111111" fill="#111111"/>
>     </flowRegion>
>       <flowPara>Tomorrow, and tomorrow, and tomorrow; creeps in this
>        petty pace from day to day, until the last syllable of recorded time.
> 
>        And all our yesterdays have lighted fools the way to dusty death.
>      </flowPara>
>   </flowRoot>
>   <path d="M90,40L40,270L260,270L210,40z" fill="none" stroke="black"
> stroke-width="5"/>
> </svg>
> 
> Anybody manages to transform this to pdf with proper text layout? Any
> comments on the current status of the SVG 1.2 support?
> 
> Here is part of my java code:
> 
> Reader domReader = DOMUtilities.createXMLDocumentReader(is);
> 
>         SAXSVGDocumentFactory saxDocFactory = new SAXSVGDocumentFactory(
>                 "org.apache.xerces.parsers.SAXParser");
>         SVGDocument svgDocument = saxDocFactory.createSVGDocument(null,
> domReader);
> 
> 
> PDFTranscoder pdfTranscoder = new PDFTranscoder();
>                     TranscoderInput tInput = new
> TranscoderInput(svgDocument);
>                     TranscoderOutput tOutput = new
> TranscoderOutput(tmpBout);
> 
>                     pdfTranscoder.transcode(tInput, tOutput);
> 
> Any help and comments will be rewarded with pure gratefulness. Regards,
> Benni




Jeremias Maerki


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