Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CC33C117F7 for ; Thu, 24 Apr 2014 07:07:47 +0000 (UTC) Received: (qmail 92924 invoked by uid 500); 24 Apr 2014 07:07:47 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 92489 invoked by uid 500); 24 Apr 2014 07:07:47 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 92481 invoked by uid 99); 24 Apr 2014 07:07:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2014 07:07:46 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of Toni.Helenius@syncrontech.com designates 194.136.144.135 as permitted sender) Received: from [194.136.144.135] (HELO espresso1.syncrontech.com) (194.136.144.135) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2014 07:07:42 +0000 Received: from ink.sad.syncrontech.com (ink.syncrontech.com [192.168.2.107]) by espresso1.syncrontech.com (Postfix) with ESMTP id 1E0CC17073 for ; Thu, 24 Apr 2014 10:07:20 +0300 (EEST) Received: from ink.sad.syncrontech.com ([192.168.2.107]) by ink.sad.syncrontech.com ([192.168.2.107]) with mapi; Thu, 24 Apr 2014 10:07:19 +0300 From: Toni Helenius To: "users@pdfbox.apache.org" Date: Thu, 24 Apr 2014 10:07:18 +0300 Subject: RE: Adding SVG images to PDF Thread-Topic: Adding SVG images to PDF Thread-Index: Ac9fg0j03dBixQwsQeqSyEmaBw025gACFI4g Message-ID: References: <20140417165038.9011.60BA733C@jeremias-maerki.ch> In-Reply-To: Accept-Language: en-US, fi-FI Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, fi-FI x-syncron-tech: ohlok27 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org 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 >=20 > Hi Toni, >=20 > could you upload a sample PDF to a public location to have a look at > it's content? >=20 > BR > Maruan Sahyoun >=20 > Am 23.04.2014 um 14:54 schrieb Toni Helenius > : >=20 > > 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 =3D PDDocument.load(new > > File("c:\\temp\\test.pdf")); PDPage chartPage =3D > > (PDPage)chartDocument.getDocumentCatalog().getAllPages().get(0); > > PDResources res =3D 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 =3D 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=E4rki > >>> _________________________________________________________ > >>> Jeremias M=E4rki, 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 > >>>> > >