pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: Draw Graphics in a PDF
Date Tue, 10 May 2016 17:40:41 GMT

> On 10 May 2016, at 09:38, Ivan Ridao Freitas <info@ivanrf.com> wrote:
> 
> Is it possible to draw a java.awt.Graphics in a PDF?

No, it’s not.

> 
> I read in previous question from 2009 and 2013 that is not implemented and will not be.
> 
> Would it be possible to add that feature to PDFBox 2.x?

Probably not because AWT has its own notions of Font and Paint which are different from
those found in PDFBox.

> Currently, I'm using Barcode4J which generates an SVG, EPS, Image or Java2D. I'm doing
fine with the PNG option. I wanted to use SVG for quality but I was not able to. So, my last
option is Java2D.

You’re likely after only a handful of drawing commands, you could use Java2D’s DebugGraphics
to find out which ones and then it wouldn’t be hard to write an absolutely minimal Graphics
implementation which draws to a PDPageContentStream.

> Drawing Graphics on a PDF would have the same quality as a SVG? or using SVG format is
the only way to draw inside a PDF?

Drawing with a PDPageContentStream gives you vector graphics equivalent in quality to SVG,
EPS, Java2D, etc.

— John

> Thanks!
> Ivan


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


Mime
View raw message