Am 04.11.2019 um 08:35 schrieb Jens Bruhn-Hansel:
Hi Tilman,
thanks for your support.
I've tried your suggestion, but I am getting this exception:
Exception in thread "AWT-EventQueue-0" java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.saveGraphicsStack(PDFStreamEngine.java:954)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processAnnotation(PDFStreamEngine.java:302)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.showAnnotation(PDFStreamEngine.java:421)
at
org.apache.pdfbox.rendering.PageDrawer.showAnnotation(PageDrawer.java:1359)
at
org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:267)
at
org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:321)
at
org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:243)
at
org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:229)
at de.pdscss.rubberstamp.PdfView.updateImage(PdfView.java:152)
at de.pdscss.rubberstamp.PdfView.addAnnotation(PdfView.java:346)
at
de.pdscss.rubberstamp.actions.AbstractAnnotationAction.addAnnotation(AbstractAnnotationAction.java:159)
at
de.pdscss.rubberstamp.actions.SquareAction.mouseReleased(SquareAction.java:37)
at
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Looking deeper into the sourcecode at your suggested methods, I am
thinking about overriding drawPage:
public void drawPage(Graphics arg0, PDRectangle
arg1) throws IOException
{
final COSBase contents =
parameters.getPage().getCOSObject().getDictionaryObject(COSName.CONTENTS);
parameters.getPage().getCOSObject().removeItem(COSName.CONTENTS);
try
{
super.drawPage(arg0, arg1);
}
finally
{
parameters.getPage().getCOSObject().setItem(COSName.CONTENTS, contents);
}
}
What do you think? Thanks again,
Yes that one was my initial idea, but to not call "processPage" in it.
Which didn't work for you (I never tried, I just looked at the source code).
Maybe your bug is because "initPage()" isn't called. So a solution would
be to replace processPage() with a call to initPage()... which isn't
possible because that is private...
How about calling processPage() with a page that has no content stream,
i.e. temporarly moving /Contents away and put it back.
Tilman
jens
Am 01.11.2019 um 17:43 schrieb Tilman Hausherr:
Hello Jens,
This can be done by modifying PageDrawer.java or make your own.
Override PageDrawer.processPage() to do nothing (see the source code
of PageDrawer.drawPage() to see why). Read the class javadoc of
PageDrawer because of the difficulties to subclass it.
Tilman
Am 01.11.2019 um 11:28 schrieb Jens Bruhn-Hansel:
Hi,
we are using PDFBox to add/modify annotations of a PDF file with
showing a preview to the user. This works well: let PDFBox rendering
the PDF (with annotations included), showing the image to the user.
But when using complex and big PDF files, it may take some seconds
to render the complete page. That's not bad, when only doing this
once. But we want to update the preview after every annotation change.
So the idea is: let PDFBox render the PDF without the annotations
once. Caching the resulting image (base). Now it would be great, to
let PDFBox render only the annotations after every change. So the
preview would be much faster: painting the cached (base) image and
painting the annotation-image. Is this possible?
Thanks a lot,
jens
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org