danfickle / danfickle/openhtmltopdf
Image is broken if interpolate is set to false in generated pdf
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
Hi @danfickle I'm trying to render a pdf which contains images more exactly some barcodes.
Initially I tried to render with interpolate set to true and I got blurry image. See (Picture_with_interpolate_true.pdf)
After I did some research I found your post in which you recommended to set interpolate to be false (image-rendering: pixelated;) I entered in debug mode and I saw that in PdfBoxSlowOutputDevice.class:712 PDImageXObject is set to true.
As result the image is broken. See (Picture_with_pixelated.pdf)
I have attached two pdfs with both cases.
I used version: '0.0.1-RC20' from 'openhtmltopdf-pdfbox'.
The image was created with code bellow :
````
private static String generateInterleafed25Image(String barcodeNumber) throws IOException {
BarcodeInter25 barcode = new BarcodeInter25();
barcode.setCode(barcodeNumber);
Image awtImage = barcode.createAwtImage(Color.BLACK, Color.WHITE);
BufferedImage newImage = new BufferedImage(
awtImage.getWidth(null), awtImage.getHeight(null),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = newImage.createGraphics();
g.drawImage(awtImage, 0, 0, null);
g.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(newImage, "png", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
return Base64.getEncoder().encodeToString(imageInByte);
}
````
Thank you!
[Picture_with_interpolate_true.pdf](https://github.com/danfickle/openhtmltopdf/files/3272094/Picture_with_interpolate_true.pdf)
[Picture_with_pixelated.pdf](https://github.com/danfickle/openhtmltopdf/files/3272095/Picture_with_pixelated.pdf)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.