You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by ph...@free.fr on 2014/11/12 10:02:09 UTC

Including PostScript in PDFBox

Hi,

is it possible to include PostScript images  on a PDPage in PDFBox?


Many thanks.

Philippe




Re: Including PostScript in PDFBox

Posted by Tilman Hausherr <TH...@t-online.de>.
Keep the jpeg at the original size, and use the drawXImage method to 
resize. Use the PDJpeg constructor that uses a stream, not the one that 
uses a BufferedImage.

Tilman

Am 12.11.2014 um 11:14 schrieb phiroc@free.fr:
> Hi John,
>
> I have exported an EPS image to a 2000 DPI PNG using Inkscape,converted the PNG to a 100%-quality JPG using Gimp, and then added the JPG image as a 300 x 27 pixel PDJpeg to a PDPage. Yet, the JDJpeg is pixelated.
>
> Is there a better way to make PDPjeg images as little pixelated as possible?
>
> Cheers,
>
> Philippe
>
>
> ----- Mail original -----
> De: "John Hewson" <jo...@jahewson.com>
> À: users@pdfbox.apache.org
> Envoyé: Mercredi 12 Novembre 2014 10:16:11
> Objet: Re: Including PostScript in PDFBox
>
> Hi Philippe,
>
> PDFBox cannot do that directly. For simple PostScript files you might be able to parse the files yourself and convert the drawing commands into equivalent PDF commands. However, for any non-trivial file you’re going to need a PostScript interpreter.
>
> If you don’t need to be 100% Java then an alternative route would be to convert your PostScript to PDF using Ghostscript and then you can use PDFBox to include that PDF image on a page.
>
> -- John
>
>> On 12 Nov 2014, at 01:02, phiroc@free.fr wrote:
>>
>> Hi,
>>
>> is it possible to include PostScript images  on a PDPage in PDFBox?
>>
>>
>> Many thanks.
>>
>> Philippe
>>
>>
>>


Re: Including PostScript in PDFBox

Posted by John Hewson <jo...@jahewson.com>.
Philippe,

It would be better to export a PDF rather than an EPS, if the software you’re using supports that, because PDFBox can easily add existing PDFs to a page as graphics.

Converting an EPS to a PNG isn’t a great idea because you’re converting vector graphics into raster graphics, but PDF is a vector format, so you’re really loosing the advantage of using PDF, i.e. vector graphics will never be pixelated.

-- John

> On 12 Nov 2014, at 02:14, phiroc@free.fr wrote:
> 
> Hi John,
> 
> I have exported an EPS image to a 2000 DPI PNG using Inkscape,converted the PNG to a 100%-quality JPG using Gimp, and then added the JPG image as a 300 x 27 pixel PDJpeg to a PDPage. Yet, the JDJpeg is pixelated.
> 
> Is there a better way to make PDPjeg images as little pixelated as possible?
> 
> Cheers,
> 
> Philippe
> 
> 
> ----- Mail original -----
> De: "John Hewson" <jo...@jahewson.com>
> À: users@pdfbox.apache.org
> Envoyé: Mercredi 12 Novembre 2014 10:16:11
> Objet: Re: Including PostScript in PDFBox
> 
> Hi Philippe,
> 
> PDFBox cannot do that directly. For simple PostScript files you might be able to parse the files yourself and convert the drawing commands into equivalent PDF commands. However, for any non-trivial file you’re going to need a PostScript interpreter.
> 
> If you don’t need to be 100% Java then an alternative route would be to convert your PostScript to PDF using Ghostscript and then you can use PDFBox to include that PDF image on a page.
> 
> -- John
> 
>> On 12 Nov 2014, at 01:02, phiroc@free.fr wrote:
>> 
>> Hi,
>> 
>> is it possible to include PostScript images  on a PDPage in PDFBox?
>> 
>> 
>> Many thanks.
>> 
>> Philippe
>> 
>> 
>> 
> 


Re: Including PostScript in PDFBox

Posted by ph...@free.fr.
Hi John,

I have exported an EPS image to a 2000 DPI PNG using Inkscape,converted the PNG to a 100%-quality JPG using Gimp, and then added the JPG image as a 300 x 27 pixel PDJpeg to a PDPage. Yet, the JDJpeg is pixelated.

Is there a better way to make PDPjeg images as little pixelated as possible?

Cheers,

Philippe


----- Mail original -----
De: "John Hewson" <jo...@jahewson.com>
À: users@pdfbox.apache.org
Envoyé: Mercredi 12 Novembre 2014 10:16:11
Objet: Re: Including PostScript in PDFBox

Hi Philippe,

PDFBox cannot do that directly. For simple PostScript files you might be able to parse the files yourself and convert the drawing commands into equivalent PDF commands. However, for any non-trivial file you’re going to need a PostScript interpreter.

If you don’t need to be 100% Java then an alternative route would be to convert your PostScript to PDF using Ghostscript and then you can use PDFBox to include that PDF image on a page.

-- John

> On 12 Nov 2014, at 01:02, phiroc@free.fr wrote:
> 
> Hi,
> 
> is it possible to include PostScript images  on a PDPage in PDFBox?
> 
> 
> Many thanks.
> 
> Philippe
> 
> 
> 


Re: Including PostScript in PDFBox

Posted by John Hewson <jo...@jahewson.com>.
Hi Philippe,

PDFBox cannot do that directly. For simple PostScript files you might be able to parse the files yourself and convert the drawing commands into equivalent PDF commands. However, for any non-trivial file you’re going to need a PostScript interpreter.

If you don’t need to be 100% Java then an alternative route would be to convert your PostScript to PDF using Ghostscript and then you can use PDFBox to include that PDF image on a page.

-- John

> On 12 Nov 2014, at 01:02, phiroc@free.fr wrote:
> 
> Hi,
> 
> is it possible to include PostScript images  on a PDPage in PDFBox?
> 
> 
> Many thanks.
> 
> Philippe
> 
> 
>