xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: SVG2PDF programatically
Date Wed, 22 Aug 2007 12:03:59 GMT
Hi Mork,

Mork0075 <mork0075@googlemail.com> wrote on 08/22/2007 07:39:09 AM:

> P.S.: when i talk about svg, i mean a String like this: 
> String svg = "<svg height=... <defs ... <g ..."

   Then all you need to do is wrap it in a StringReader
and pass that to the TranscoderInput constrcutor instead of the 
already build DOM document.

> Steffen Jacobs schrieb:
> > Now that i read your question again more carefully, I am not sure what
> > you mean by 'convert a svg string'.
> >
> > Do you have a valid SVG file, or just some XML/SVG snippets to 
convert?
> > In the former case, you can use batik to get the SVGDocument tree of
> > your file, create a new PDFTranscoder object and use the
> > transcode(input, output) method as written in my example.
> >
> > In the latter case, you have to create a SVGDocument first, add your 
SVG
> > 'snippets' to the document tree and use transcode again. To do so just
> > copy'n'paste my code example and insert your svg snippets into the
> > document tree after the line marked with
> >
> > // ... draw some shapes ...
> >
> > and replace the next line with something like
> > File pdf = new File('mypdf.pdf');
> >
> >
> >
> >
> > Mork0075 wrote:
> > 
> >> Thank you Steffen, but where comes the svg snippet in place, which
> >> already exists?
> >>
> >> Steffen Jacobs schrieb:
> >> 
> >> 
> >>> Hi,
> >>>
> >>> you can try the pdf-transcoder library. An example from another 
forum
> >>> may help:
> >>>
> >>> DOMImplementation impl = 
SVGDOMImplementation.getDOMImplementation();
> >>>      String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> >>>      Document document = impl.createDocument(svgNS, "svg", null);
> >>>      SVGGraphics2D g2d = new SVGGraphics2D(document);
> >>> 
> >>>      // ... draw some shapes ...
> >>>      File pdf = ...
> >>> 
> >>>      OutputStream out = new FileOutputStream(pdf);
> >>>      PDFTranscoder t = new PDFTranscoder();
> >>>      TranscoderInput input = new TranscoderInput(document);
> >>>      TranscoderOutput output = new TranscoderOutput(out);
> >>>      try {
> >>>          t.transcode(input, output);
> >>>      } catch (Exception ex) {
> >>>          throw new IOException(ex.getMessage());
> >>>      } finally {
> >>>          out.flush();
> >>>          out.close();
> >>>      }
> >>>
> >>>
> >>> Regards,
> >>> Steffen
> >>>
> >>>
> >>> Mork0075 wrote:
> >>> 
> >>> 
> >>> 
> >>>> Hello,
> >>>>
> >>>> can anyone give me a piece of code how to convert a svg string into

a
> >>>> pdf file?
> >>>>
> >>>> Thanks a lot :)
> >>>>
> >>>> 
---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >>>> For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >>>> 
> >>>> 
> >>>> 
> >>>> 
> >>> 
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >>> For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >>>
> >>>
> >>> 
> >>> 
> >>> 
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >> For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >> 
> >> 
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >
> >
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Mime
View raw message