PdfBox-Android
PdfBox-Android copied to clipboard
Does not render PDF with annotations 100%
I have pdf with annotations and the rendered image is incomplete and missing alot of content.
Please attach your PDF.
Here is the sample pdf. The password is 123456 I'm just rendering the first page.
Here is what it rendered.
Most be some Android specific problem. I tried with PDFBox for desktop from 1.8.16 down to 1.8.1 and it displays nicely.
can you confirm if this is the problem with the current Android build?
Don't know, I'm not developing for Android currently. I thought this was a problem with annotations and I was wondering whether it would fail with the desktop project.
This is an definitely an Android specific problem. It looks like it's being caused by PageDrawer.getCurrentPoint(), which is basically unimplemented due to a difference in Android's Path class vs. Java's GeneralPath.
That makes sense, the two lines appear to go in the direction (0,0). getCurrentPoint is only used by CurveToReplicateInitialPoint ("v"), which is used twice in the content stream of page 1. But that should be easy to fix, by storing the current point when moveTo, lineTo and curveTo are called.
Implementing that properly fixed a couple of the rendered artifacts, but there are still bugs from #92 that I need to debug to get the rest of the letters to render.
Cool. Please let me know when this is fixed. Need annotation in our project badly.
From what I see (PageDrawer.java), the current Android code does not support rendering of annotations that don't have an appearance stream, only those that have. The 2.0 released version for desktop supports rendering of Link and Ink annotations. There is uncommitted code for 2.0 attached in https://issues.apache.org/jira/browse/PDFBOX-3353 for more annotation types. It is uncommitted because it became too bulky. Further development was done for the trunk only, which can display most annotation types.
I downloaded https://github.com/barteksc/AndroidPdfViewer and I can view annotations.
Are both library using the same pdfbox build?
AndroidPdfViewer uses PdfiumAndroid for rendering, not PDFBox, which is why you're able to see your annotations.