I have a simplified PDF case that renders (using PDFBox) differently between 
JPG and SVG output modes.  

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.  For this mode, I am using the 
PdfBox PDFRenderer call 'renderImageWithDPI', which renders to a BufferedImage, 
which I then save to JPG.

        String sJpgPageSpec = GenericUtil.PathMake(sDestPath, 
sPagePrefix+"-page-"+nPageNdx+".jpg");
        File oFileJpg = new File(sJpgPageSpec);
        BufferedImage image = oRender.renderImageWithDPI(nPageNdx, 
GenericUtil.parseInt(sDpi, 300));
       ImageIO.write(image, "JPEG", oFileJpg);

When rendered to SVG, the rectangle is filled with opaque black. For this mode, 
I am using the PdfBox PDFRendender call 'renderPageToGraphics', which renders 
to an AWT Graphics Object, supplied by Batik 1.17.

        // setup instance of SVG Generator
        eqSVGGraphics2D oSvgGen = new eqSVGGraphics2D( oCtx, false );
        // render the page to SVG
        oRender.renderPageToGraphics( nPageNdx, oSvgGen, ((float) nDpi)/72 );


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 

Reply via email to