pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Adding SVG images to PDF
Date Fri, 16 May 2014 18:07:45 GMT
Hi Toni,

no problem. I did answer last week but the mail might have been lost as there were some outages.


The reason you can’t get an XObject is because there is none. The chart is constructed using
drawing commands. The best option is to import the page as an XObject form and crop it to
the charts dimensions.

BR

Maruan Sahyoun

Am 15.05.2014 um 09:42 schrieb Toni Helenius <Toni.Helenius@syncrontech.com>:

> Hello Maruan,
> 
> sorry to haunt you like this :) Were you able to access the Dropbox link now?
> 
>> -----Original Message-----
>> From: Toni Helenius [mailto:Toni.Helenius@syncrontech.com]
>> Sent: 6. toukokuuta 2014 9:29
>> To: users@pdfbox.apache.org
>> Subject: RE: Adding SVG images to PDF
>> 
>> Hello,
>> 
>> oh yes, I failed to configure the Dropbox link. It said that even I'm
>> not allowed to access it. Here, now it should work:
>> https://www.dropbox.com/s/kojja4dt03k78gm/test.pdf
>> 
>>> -----Original Message-----
>>> From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de]
>>> Sent: 6. toukokuuta 2014 9:22
>>> To: users@pdfbox.apache.org
>>> Subject: Re: Adding SVG images to PDF
>>> 
>>> Hi Toni,
>>> 
>>> to get to the PDF I need to create an account at dropbox. Is there
>>> another way to share it or a different setting in dropbox?
>>> 
>>> BR
>>> Maruan Sahyoun
>>> 
>>> Am 06.05.2014 um 08:18 schrieb Toni Helenius
>>> <Toni.Helenius@syncrontech.com>:
>>> 
>>>> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message