[
https://issues.apache.org/jira/browse/PDFBOX-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18072304#comment-18072304
]
Tilman Hausherr edited comment on PDFBOX-5597 at 4/9/26 1:42 PM:
-----------------------------------------------------------------
Back to this... here's the test file:
[^PDFBOX-5597-jbig2subsamplingproblem.pdf]
code to create it:
{code:java}
try (PDDocument doc = new PDDocument())
{
PDPage page = new PDPage(new PDRectangle(0, 0, 2383.94f, 1683.81f));
doc.addPage(page);
try (PDPageContentStream cs = new PDPageContentStream(doc, page))
{
BufferedImage bim = new BufferedImage(9602, 6782,
BufferedImage.TYPE_INT_RGB);
// image drawing code by ChatGPT
Graphics2D g2d = bim.createGraphics();
// Enable anti-aliasing for smoother lines
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, bim.getWidth(), bim.getHeight());
g2d.setColor(Color.BLUE);
int w = 100;
g2d.setStroke(new BasicStroke(w));
int width = bim.getWidth();
int height = bim.getHeight();
// Draw lines from corners (forming an "X")
g2d.drawLine(0, 0, width, height); // top-left to
bottom-right
g2d.drawLine(0, height, width, 0); // bottom-left to
top-right
int offset = w / 2; // half of stroke width (approx)
g2d.drawRect(offset, offset, width - 1 - 2 * offset, height - 1
- 2 * offset);
g2d.dispose();
PDImageXObject img = JPEGFactory.createFromImage(doc, bim);
cs.drawImage(img, 0, 0, 2383.9448f, 1683.8069f);
}
doc.save("PDFBOX-5597-jpeg-test.pdf");
}
{code}
The sizes in the decoder are the correct ones, so the problem is in the jbig2
decoder.
was (Author: tilman):
Back to this... here's the test file:
[^PDFBOX-5597-jbig2subsamplingproblem.pdf]
code to create it:
{code:java}
try (PDDocument doc = new PDDocument())
{
PDPage page = new PDPage(new PDRectangle(0, 0, 2383.94f, 1683.81f));
doc.addPage(page);
try (PDPageContentStream cs = new PDPageContentStream(doc, page))
{
BufferedImage bim = new BufferedImage(9602, 6782,
BufferedImage.TYPE_INT_RGB);
// image drawing code by ChatGPT
Graphics2D g2d = bim.createGraphics();
// Enable anti-aliasing for smoother lines
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, bim.getWidth(), bim.getHeight());
g2d.setColor(Color.BLUE);
int w = 100;
g2d.setStroke(new BasicStroke(w));
int width = bim.getWidth();
int height = bim.getHeight();
// Draw lines from corners (forming an "X")
g2d.drawLine(0, 0, width, height); // top-left to
bottom-right
g2d.drawLine(0, height, width, 0); // bottom-left to
top-right
int offset = w / 2; // half of stroke width (approx)
g2d.drawRect(offset, offset, width - 1 - 2 * offset, height - 1
- 2 * offset);
g2d.dispose();
PDImageXObject img = JPEGFactory.createFromImage(doc, bim);
cs.drawImage(img, 0, 0, 2383.9448f, 1683.8069f);
}
doc.save("PDFBOX-5597-jpeg-test.pdf");
}
{code}
> The image drawn is garbled
> --------------------------
>
> Key: PDFBOX-5597
> URL: https://issues.apache.org/jira/browse/PDFBOX-5597
> Project: PDFBox
> Issue Type: Bug
> Reporter: liu
> Priority: Major
> Labels: jbig2, subsampling
> Attachments: PDFBOX-5597-jbig2subsamplingproblem.pdf, image0.jpg,
> image17.pdf, screenshot-1.png, screenshot-2.png, screenshot-3.png, test.pdf,
> test6.pdf
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]