Hi,

Using losslessFactory is the only idea I had. I don't know where the line comes from. I suspect it's a "feature" in the graphics engine of some products.

Tilman

On 02.08.2023 22:05, JJ Blodgett wrote:
This image limitation is a pain. But here is some code:
var mediaBox = newPDPage.getMediaBox();
var imgWidth = Int(mediaBox.getUpperRightX());
var imgHeight = Int(mediaBox.getUpperRightY());

var bufferedImage = objRender.renderImageWithDPI(i, dpi, 
objImageType[url.colorSpace]);

var newPDImage = newJPEGFactory.createFromImage(newPDDocument, bufferedImage, 
url.quality, dpi);
var newPDImageLL = newLosslessFactory.createFromImage(newPDDocument, 
bufferedImage);

//newPDPageContentStream.drawImage(newPDImage, 0, 0, imgWidth, imgHeight);
newPDPageContentStream.drawImage(newPDImageLL, 0, 0, imgWidth, imgHeight);

I forgot that I had also tried the losslessFactory and it does work to generate 
/ draw images but is also much larger filesize so not an option either. And 
when I do it high quality, it still prints the borders around the images and 
form fields. So didn't even solve the problem. I just can't figure out which 
step is introducing the border. The raw png files seem to be pristine so it's 
as I'm putting them back together I guess.

________________________________
From: JJ Blodgett <jj.blodg...@silvervinesoftware.com>
Sent: Wednesday, August 2, 2023 12:47 PM
To: users@pdfbox.apache.org <users@pdfbox.apache.org>
Subject: Re: Border / Box around images and form elements with backgrounds


EXTERNAL: Do not click links or open attachments if you do not recognize the 
sender.

Ok. Gotcha. What I'm doing is to create the image on the fly (as buffered 
image), then directly drawing the image using a JPEGFactory response. So maybe 
that's where it's getting hosed up. There are options to drawImage from content 
read from a file but we're trying to avoid that if possible to eliminate disk 
I/O as a bottleneck when dealing with multiple thousands of images.

[cid:ba407754-72d1-481d-8d9c-a271163b0497]

Maybe one of these 2 steps (likely the first one) is where this is getting 
introduced. I haven't found a way to directly draw a bufferedImage of a PNG 
into a PDF without writing to file first. I'm new to the PDFBox side of things 
so don't have a firm grasp on all of the possibilities yet.

________________________________
From: Tilman Hausherr <thaush...@t-online.de>
Sent: Wednesday, August 2, 2023 11:27 AM
To: users@pdfbox.apache.org <users@pdfbox.apache.org>
Subject: Re: Border / Box around images and form elements with backgrounds


EXTERNAL: Do not click links or open attachments if you do not recognize the 
sender.

On 02.08.2023 18:11, JJ Blodgett wrote:

Not sure what you mean about ARGB being jpeg. The examples I provided should 
have been PNG.

Here's what I mean - the image in the PDF is a JPEG encoded image with a b/w JPEG 
("DCTDecode" is JPEG) encoded mask. Using JPEG is a weird idea for b/w images, 
CCITT 4 is best. I'm wondering if the non-matching is because of the weird compression.

[cid:part1.0ze00fN2.5NiM0jXY@t-online.de]


Tilman



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

Reply via email to