pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toni Helenius <Toni.Helen...@syncrontech.com>
Subject RE: Adding SVG images to PDF
Date Tue, 06 May 2014 06:18:10 GMT
Hi Maruan,

have you had the time to look upon this issue? Or have you given up on it? :)

> -----Original Message-----
> From: Toni Helenius [mailto:Toni.Helenius@syncrontech.com]
> Sent: 24. huhtikuuta 2014 10:07
> To: users@pdfbox.apache.org
> Subject: RE: Adding SVG images to PDF
> 
> Hi,
> 
> here is the Batik generated PDF. Batik is at 1.7 version and PDFBox in
> 1.8.4.
> 
> https://www.dropbox.com/s/9cxwt3n24cbbbim/test.pdf
> 
> > -----Original Message-----
> > From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de]
> > Sent: 24. huhtikuuta 2014 9:06
> > To: users@pdfbox.apache.org
> > Subject: Re: Adding SVG images to PDF
> >
> > Hi Toni,
> >
> > could you upload a sample PDF to a public location to have a look at
> > it's content?
> >
> > BR
> > Maruan Sahyoun
> >
> > Am 23.04.2014 um 14:54 schrieb Toni Helenius
> > <Toni.Helenius@syncrontech.com>:
> >
> > > Hi again,
> > >
> > > I created a new PDF file with Batik transcoder thingie. The file
> has
> > one page with the SVG embedded in it. What I want is to embed it in
> > another PDF, to an existing page.
> > >
> > > If I open the new SVG PDF with PDFBox, I'm unable to extract the
> SVG.
> > > PDDocument chartDocument = PDDocument.load(new
> > > File("c:\\temp\\test.pdf")); PDPage chartPage =
> > > (PDPage)chartDocument.getDocumentCatalog().getAllPages().get(0);
> > > PDResources res = chartPage.findResources(); res.getXObjects(); <--
> -
> > > No objects
> > >
> > > This extracting might not be necessary, I do not know yet. The PDF
> > page is somewhat larger than the SVG itself, so I recon it is
> > necessary so that no ugly borders are introduced.
> > >
> > > Soooo, I have difficulties adding the page as such. I'm trying
> > > PDXObjectForm obj = new PDXObjectForm(chartPage.getContents()); --
> > > Create new object contentStream.drawXObject(obj, 20, 180, 265,
> 200);
> > > -- Add to already open page
> > >
> > > This code creates a PDF that Acrobat Reader reports having problems
> > in it. But opens it anyway, obviously without the added content...
> > >
> > >> -----Original Message-----
> > >> From: Toni Helenius [mailto:Toni.Helenius@syncrontech.com]
> > >> Sent: 22. huhtikuuta 2014 8:33
> > >> To: users@pdfbox.apache.org
> > >> Subject: RE: Adding SVG images to PDF
> > >>
> > >> Hi,
> > >>
> > >> thank you for the quick answer. We are already using Batik so it
> > >> seems this is an easy thing after all.
> > >>
> > >> I also managed to get some decent results by generating PNG images
> > 10
> > >> times larger than that I would display on the PDF (PDImage
> scales).
> > >> It displayed very ok even with huge zoom levels. And didn't even
> > grow
> > >> the PDF file size much. But SVG would be better still. Thank you!
> > >>
> > >>> -----Original Message-----
> > >>> From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> > >>> Sent: 17. huhtikuuta 2014 17:51
> > >>> To: users@pdfbox.apache.org
> > >>> Subject: Re: Adding SVG images to PDF
> > >>>
> > >>> Hi Toni,
> > >>>
> > >>> well, not directly. What you could do is to create a PDF from SVG
> > >>> using Apache Batik [1][2] or Apache FOP [3][4] and then import
> the
> > >> PDF
> > >>> into your own PDFBox-made PDF document, either by importing the
> > >>> PDF
> > >> as
> > >>> a page [5] or as a form XObject, if you want to place the SVG on
> > >>> an existing page.
> > >>>
> > >>> [1] http://xmlgraphics.apache.org/batik/using/transcoder.html
> > >>> [2] http://stackoverflow.com/questions/6875807/convert-svg-to-pdf
> > >>> [3] http://xmlgraphics.apache.org/fop/
> > >>> [4] By putting a reference to the SVG into a little XSL-FO
> wrapper.
> > >>> FOP also allows conversion from SVG to PDF on the command-line
> > using
> > >>> "fop - imagein myimage.svg -pdf out.pdf".
> > >>> [5] http://pdfbox.apache.org/commandline/#pdfMerger
> > >>>
> > >>> HTH,
> > >>> Jeremias Märki
> > >>> _________________________________________________________
> > >>> Jeremias Märki, Software-Development and Consulting Contact
> > >>> Information and Public Keys:
> > >>> http://www.jeremias-maerki.ch/contact.html
> > >>>
> > >>> Please don't print e-mails. Strive to become paperless.
> > >>> Avoid media breaks. Cherish metadata.
> > >>>
> > >>>
> > >>> On 17.04.2014 12:59:55 Toni Helenius wrote:
> > >>>> Hello,
> > >>>>
> > >>>> is there any way to add SVG images to a PDF file using PDFBox?
> > >>>> Any
> > >>> help is highly appreciated!
> > >>>>
> > >>>> --
> > >>>> Toni Helenius
> > >>>>
> > >


Mime
View raw message