[
https://issues.apache.org/jira/browse/PDFBOX-6094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18035834#comment-18035834
]
Tilman Hausherr edited comment on PDFBOX-6094 at 11/6/25 1:27 PM:
------------------------------------------------------------------
You're right... I think that the previous version disregarded the clip (because
it was handled in the missing "n") which is why it worked. The current version
uses it but has a weakness rendering when clipping and stroking are close. This
is a very old bug: PDFBOX-1288. Btw the PDF file gets rendered properly when
the resolution is higher (it works at 400% in PDFDebugger). The flaws in the
lower resolutions are different, sometimes it's bottom and left lines that are
wrong, sometimes top and right.
was (Author: tilman):
You're right... I think that the previous version disregarded the clip (because
it was handled in the missing "n") which is why it worked. The current version
uses it but has a weakness rendering when clipping and stroking are close. This
is a very old bug, I don't have the number. Btw the PDF file gets rendered
properly when the resolution is higher (it works at 400% in PDFDebugger). The
flaws in the lower resolutions are different, sometimes it's bottom and left
lines that are wrong, sometimes top and right.
> After upgrading pdfbox, the lines on the right and bottom have become hard to
> see.
> ----------------------------------------------------------------------------------
>
> Key: PDFBOX-6094
> URL: https://issues.apache.org/jira/browse/PDFBOX-6094
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.35
> Reporter: bai yuan
> Priority: Major
> Attachments: border.png, export_2.0.35_2.pdf
>
>
> After upgrading pdfbox from 2.0.32 to 2.0.35, the lines on the right and
> bottom have become hard to see. Is this change expected? What parts of the
> code should I modify if I want the previous effect?
> {code:java}
> // Some comments here
> PDDocument doc = new PDDocument();
> BufferedImage bi = new BufferedImage(647, 168, 2);
> Graphics2D graphics = bi.createGraphics();
> java.awt.Color backgroundColor = java.awt.Color.WHITE;
> graphics.setBackground(backgroundColor);
> graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
> RenderingHints.VALUE_ANTIALIAS_ON);
> PDPage pdPage = new PDPage(new PDRectangle(647,168));
> doc.addPage(pdPage);
> try (PDPageContentStream pdPageContentStream = new
> PDPageContentStream(doc, pdPage)){
> // pdPageContentStream.saveGraphicsState();
> //// pdPageContentStream.addRect(0.0f, 1.6f,
> //// 646.7868f, 166.4f);
> //// pdPageContentStream.clip();
> pdPageContentStream.saveGraphicsState();
> PDExtendedGraphicsState graphicsState = new
> PDExtendedGraphicsState();
> graphicsState.getCOSObject().setItem(COSName.BM, COSName.NORMAL);
> graphicsState.setNonStrokingAlphaConstant(1.0f);
> pdPageContentStream.setGraphicsStateParameters(graphicsState);
> pdPageContentStream.setNonStrokingColor(68, 114, 196);
> PDExtendedGraphicsState graphicsState2 = new
> PDExtendedGraphicsState();
> graphicsState2.getCOSObject().setItem(COSName.BM, COSName.NORMAL);
> graphicsState2.setStrokingAlphaConstant(1.0f);
> pdPageContentStream.setGraphicsStateParameters(graphicsState2);
> pdPageContentStream.setLineCapStyle(0);
> pdPageContentStream.setLineJoinStyle(1);
> pdPageContentStream.setLineWidth(1.28f);
> pdPageContentStream.moveTo(92.39811f, 148.80008f);
> pdPageContentStream.lineTo(554.3887f, 148.80008f);
> pdPageContentStream.lineTo(554.3887f, 20.80008f);
> pdPageContentStream.lineTo(92.39811f, 20.80008f);
> pdPageContentStream.closePath();
> pdPageContentStream.appendRawCommands("W ");
> pdPageContentStream.stroke();
> pdPageContentStream.restoreGraphicsState();
> // pdPageContentStream.restoreGraphicsState();
> } finally {
> try {
> doc.save(new ByteArrayOutputStream());
> new PDFRenderer(doc).renderPageToGraphics(0, graphics, 1.0f,
> 1.0f);
> } catch (IOException e) {
> // ignored
> }
> }
> File file = new File("export_2.0.35_2.png");
> ImageIO.write(bi, "png", file);
> doc.close();
> graphics.dispose();
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]