[ https://issues.apache.org/jira/browse/PDFBOX-3353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16141833#comment-16141833 ]
Tilman Hausherr commented on PDFBOX-3353: ----------------------------------------- I think what you really meant is that all (!) non horizontal lines are wrong in the second half, and that is gets worse depending on the rotation. Thanks for finding this. What a weird feeling to look at one's own code after over a year. Luckily there's a comment that explains what the rotation is about: working horizontally. I believe my mistake was to use the x1 x2 values for the length of the line. This is wrong, I must use linelength. So here's the segment corrected, the wrong code is in comment: {code} if ("Top".equals(captionPositioning)) { // Add 1/2 of size yOffset = 6; cs.moveTo(0, 0); //cs.lineTo(x2 - x1, 0); cs.lineTo(lineLength, 0); cs.stroke(); } else { // Inline yOffset = -3; cs.moveTo(0, 0); cs.lineTo(0 + xOffset, 0); //cs.moveTo(x2 - x1 - xOffset, 0); cs.moveTo(lineLength - xOffset, 0); //cs.lineTo(x2 - x1, 0); cs.lineTo(lineLength, 0); cs.stroke(); } {code} Another thing I should change is the offset calculation. "- 12" looks terrible, "-1" is ok. I'm also wondering why that code does nothing if {{line.getCaption()}} returns false. But that's easy to fix, add this code (must be refactored to remove double code): {code} else { double angle = Math.atan2(y2 - y1, x2 - x1); cs.transform(Matrix.getRotateInstance(angle, x1, y1)); float lineLength = (float) Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); cs.moveTo(0, 0); cs.lineTo(lineLength, 0); cs.stroke(); } {code} Drawing arrows should also be easy thanks to the horizontal strategy... the only thing to decide is how long the arrow part should be. > Create appearance streams for annotations > ----------------------------------------- > > Key: PDFBOX-3353 > URL: https://issues.apache.org/jira/browse/PDFBOX-3353 > Project: PDFBox > Issue Type: Task > Components: PDModel, Rendering > Affects Versions: 1.8.12, 2.0.0, 2.0.1, 2.0.2, 3.0.0 > Reporter: Tilman Hausherr > Labels: Annotations > Attachments: line_dimension_appearance_stream.pdf, > PDFBOX-3353-highlight-noAP-001796-p1.pdf, PDFBOX-3353-highlight-noAP.pdf, > showAnnotation.java, SquareAnnotations.pdf > > > Create appearance streams for annotations when missing. > I'll start by replacing current code for Ink and Link annotations. > Good example PDFs: > http://www.pdfill.com/example/pdf_commenting_new.pdf > https://github.com/mozilla/pdf.js/issues/6810 -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org