-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object Renderer link placement #477
Comments
I have debugged my way into According to @danfickle, @rototor, do you have an idea, whether this makes any sense? The final result shows that the whole Rect works as a link and that the area marked by the QuadPoints seems to be irrelevant. |
I just had a quick look, somethings seems to be broken here. My freemarker example with the JFreeChart pie has no longer correct shapes for the pie. See featuredocumentation.ftl Just for your understanding:
See also https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf - 12.5.6.5 I'll try to investigate that, but I can not tell you exactly when I will find time. Maybe it got broken when porting to the "Fast" mode. |
Thank you for checking. Well AdobeReader unfortunately behaves the same as the Firefox internal PDF viewer. I just chose the latter for the screenshot, because it highlights links. I am currently diving into the PDF specification about annotations and this rises a number of questions. For example, F=4 means NoZoom:
Should the shape of the annotation not zoom with the page? And Adobe's own specification does not define QuadPoints as supported for annotations of type "link", only for Freetext-Markup. |
There's something stange happing with transformations where the QuadPoints are mapped. I understand, why the coordinate system must be mirrored vertically, but I am unsure, where the original scale and translation originate from and I am currently unsure, whether the transformations are applied in the correct order. I managed to see a few link rects after dropping the translation part from the transform, but the scales where not correct and the order of columns seemed randomized. It appears as if somewhere x and y axis had been confused, scaled and a quantization applied, maybe through casting from double to float or float to int somewhere. I still do not have a real trace. Any help is much appreciated. |
The issue is equally present in "Slow" mode, too. Like always in developer reality, when issues arise, they are instantaneously pressing. :) But I am in no position to press on you. I am already impressed and thankful for how quickly you and Dan responded to my issue. I will gladly help on solving the issue, but I am having a really hard time, understanding the way the transformation context is developing while traversing the input and in which coordinate space I am on what level of the scene graph. I've already forked openhtml2pdf and managed to compile the library locally. Some tests are failing, though. |
Thanks to git bisect I know for sure that 1ffd271 broke the shape creation. Does not make that much sense from a pure look on the commit, as it seems fine. I'll investigate future. |
For whatever reason we only want the DPI scaling from the given transform, and not any other property of the transform. When adding a link to process later, the transform has at that moment also a translate in it. Before 1ffd271 the used transform was after the last page was processed. At that moment the transform only had a scale component and no translate.
I found a fix for this, see the pull request #480 I'm not 100% sure that this is always the correct fix, but at least it fixes my test case. And it makes "mildly" sense. |
I applied that to my local clone and, yes, it works for my graph, too. So it is at least more correct than before. :) |
So do you think, this fix could be released soon? |
Two more things still worry me:
|
The rectangle intersection sounds like an adequate solution. Just ping me, when I can apply a patch or if you need help. Yes rendering page numbers is a multi-pass task in dynamic layouts. If I remember correctly, LaTeX requires three passes to ensure line- and page-breaks are corrected after insertion of the page number references, because they themselves change the text length again. And then you still have no guarantee to have the optimal solution. How does OpenHtmlToPdf accomplish this in general? Placeholders? Two-Pass rendering? I wonder, whether generating an abstract intermediate tree before materializing the actual PDF stream would help. The intermediate representation could use extended implementations of Rects managed by a factory, which "know" that they are not final until the first pass has completed. That's the method I am using for calculating arrow endpoints in the graph. The nodes have to be layed out first, because I do not even know their sizes and order before. And SwingUtilities can calculate absolute positions for me implicitly flattening the transformation graph from the container hierarchy. I am not afraid to parse the PDF tree, it's just, it is always less error prone to save additional information explicitly when generating it, instead of parsing and interpreting intermediate results in a foreign format. |
Yes, those classes are copies, so there is duplication. But before extending this method I rather have it only in one place.
…ing box of the shape.
I've implemented the this reduced bounding box in the #480 pull request branch. You can test it there. I know that the link annotations are placed in the pages at the very end of the process after all pages have been generated. And that the page break logic is rather complex and also modifies the render DOM in place while performing page breaks. I.e. an object that spans multiply pages will be drawn multiple times, i.e. for every page it is on with changed positions. I think that is a little bit dirty that way, but it's that way here for a very long time (that was also in flyingsaurcer that way). No idea how this CSS counter stuff is implemented. |
And Adobe Reader still works, too. |
About the printable page numbers: My first step will be a separate references list, because I need a quick solution as part of explicitly splitting the graph for display on several pages with a guaranteed effective font size in print. So the amount of nodes per page will be limited as well. |
Assumed solved by #480 - please reopen as required. |
As outcome of #475 I am now rendering a tree graph using a custom object renderer based on Graphics2D. but I am now having extreme difficulties to getting the hyperlink boxes for the nodes in my graph correctly, which link to description pages in my document. By seeing where the mouspointer turns into a finger icon in Acrobat Reader I can see, that all link shapes seem to cover almost the whole region covered by the object. It does not matter, where I klick, it opens the same link, so this single link covers the whole region.
The display itself works fine and I am able to scale the graph to fit it in the page width. The graph consists of nodes connected by arrows. Each node is built from a Swing JPanel that lays out JLabels for Node ID, title, node information and outgoing edge ports using GridBagLayout. The nodes themselves are organized in a large JPanel using two nested GridBagLayouts. Again positioning works great and using SwingUtilities.convertRectangle I am able to determine the exact position relative to the main panel of each Title and NodeID label that is supposed to carry a link.
To collect the link shapes, I have extended the JLabel Component with an Interface that provides the url. So during rendering in the custom object drawer, I am able to collect all linked components after layout completes, calculate their bounding shapes relative to the Graphics 2D and create the link map, with shapes as keys and urls as values.
I have verified that the positions of the collected shapes match the drawn Ids and titles by drawing them as red boxes at the end of graph drawing. The cover exactly the areas that are supposed to be the hotspots of the links. But if I return the shape-to-url map and let opengtmltopdf even render just the firdt link, its hotspot covers almost the whole page, instead of the title it is supposed to cover.
I have tried several corrective transformations, even transforms I would expect to result in an extremely small region in the upper left corner on the page, but it does not change anything. It is still the whole region reacting to the click.
Since it does not seem to matter, how large or small I transform the collected link shapes, I think this is a bug and I do not have a clue, how to get it right.
The text was updated successfully, but these errors were encountered: