Hi,

There's also XStep and YStep that matter. I can't tell you the actual increments. You should trace through the code.

> Is there an example in the PDFBox code that draws a pattern when outputting to renderImageWithDpi()

Isn't your PDF such an example? Alternatively create a PDF that uses patterns, you can use the CreatePatternsPDF.java example from the source code download.

Btw the tiling patterns won't be the only problem you'll get. Shading patterns might also be troublesome. Try the PDFs from this ticket: https://issues.apache.org/jira/browse/PDFBOX-1915 , start with the ch14.pdf  file, see the first and last pages.

Tilman

On 24.06.2024 16:41, Rich Stafford wrote:
Tilman,

The TIlingPaint object has attributes of a TexturePaint and a PatternMatrix.

In my case, the TexturePaint has a BufferedImage, and four attributes: sx, sy 
(values 0.2439,0.2439) and tx, ty (values 0.0,0.0).

The PatternMatrix is just an identity matrix.

I can get the Rectangle2D for the shape to be painted.

  From all of that, what would be the coordinate increments to draw the image 
across the shape?

Is there an example in the PDFBox code that draws a pattern when outputting to 
renderImageWithDpi()?

Rich
***
Tilman,

Yes, this is the same project from last year.  I suspended it in the interim 
for other priorities.

It's still a goal for us, SVG is a much better, scalable representation of many 
PDF documents.  We are getting really close to having it be a good solution.

I'm going to experiment with doing the pattern across the range block of the 
shape.  Hopefully that will handle this issue.

Rich

At 08:03 AM 6/24/2024, Tilman Hausherr wrote:
Hi,

TexturePaint is used for patterns, i.e. rectangles that repeat itself. 
GetImage() returns a single pattern image. You can test this by saving that 
BufferedImage with ImageIO.write() and look what's in it.

About your problem: the cause is either a bug in Batik, or a missing 
implementation there, or that it's impossible (does SVG have a concept about 
patterns?), or the cause is an old bug in renderPageToGraphics(), that it fails 
when there is some sort of transformation. I don't remember what ticket number 
it is, but it's many years old, and we haven't been able to fix it.

Tilman

On 24.06.2024 13:39, Rich Stafford wrote:
I am still working on getting the hatched object in a PDF to render when 
generating SVG, using the SVGGraphics2D output, called from the PDFBox 
PDFRenderer.renderPageToGraphics() method.

I have subclassed SVGGraphics2D class, specifically the fill(Shape s) method.  
For my PDF hatch data, this method is being called with a PDFBox TilingPaint 
object.  This class is 'private', but for testing, I've modified it to 'public' 
to be able to access from my module.

The TilingPaint object has an AWT 'Paint' member, which is an AWT 
'TexturePaint' object.  I am able to use it's 'getImage()' method to access a 
BufferedImage object.

My question is, what is contained in that BufferedImage object?  Does it 
contain the same rendered view of the hatched PDF data as I can see when I 
generate a full raster view using PDFRenderer.renderImageWithDPI() method?

Rich
***
At 02:01 AM 6/18/2024, Andreas Lehmkühler wrote:
Hi,

Am 18.06.24 um 01:10 schrieb Rich Stafford:
I have a simplified PDF case that renders (using PDFBox) differently between 
JPG and SVG output modes.
PDFBox doesn't have a SVG output mode. I guess you are using some code/tool 
from the Apache XMLGraphics project so that you might ask them for help.

https://xmlgraphics.apache.org/

Andreas

This PDF has a simple line element, and a lime colored rectangle that is filled 
with some lime color horizontal lines and shows the black line behind it.
When rendering to JPG, it matches the input PDF.
When rendered to SVG, the rectangle is filled with opaque black.
I am using PDFBox 3.0.2, and Batik 1.17.
The following link is to an open share of a file 't2.zip.  In this zip is:
   t2.pdf       the PDF being rendered
   t2.jpg               the rendered JPG file
   t2.svg       the rendered SVG file
https://drive.google.com/file/d/1qbuM6O-yNdbr8Ip32q6jp0Z9demfSZBe/view?usp=sharing
Any help or advice would be appreciated!
Rich Stafford
Chief Scientist
eQuorum Corporation

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

Reply via email to