Skip to content
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

DocumentCloud not properly processing PDF annotations #155

Open
duckduckgrayduck opened this issue Aug 18, 2023 · 0 comments
Open

DocumentCloud not properly processing PDF annotations #155

duckduckgrayduck opened this issue Aug 18, 2023 · 0 comments
Labels
bug Something isn't working some day

Comments

@duckduckgrayduck
Copy link
Contributor

Summary of the problem

PDFium is not properly picking up on some PDF annotations, instead dropping them which ends up removing content from the document upload.

StackOverflow users suggested two possible fixes:

In PDFium there is an FPDF_ANNOT flag that can be passed to the various FPDF_RenderPage* methods. It's possible the PDFiumViewer code provides the same flag somewhere.

or

doc = PDDocument.load(FilePath);
PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get(pageNum);
int rotPD = page.findRotation();
PDRectangle pageBound = page.findCropBox();
PDRectangle rect = ModifyRectAccordingToRotation(rectangle, rotPD, pageBound);
PDAnnotationLink txtLink = new PDAnnotationLink();
    PDBorderStyleDictionary borderULine = new PDBorderStyleDictionary();
                    borderULine.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
borderULine.setWidth(0);
txtLink.setBorderStyle(borderULine);
PDActionRemoteGoTo remoteGoto = new PDActionRemoteGoTo();
PDComplexFileSpecification fileDesc = new PDComplexFileSpecification();
fileDesc.setFile(System.IO.Path.GetFileName(path));
remoteGoto.setOpenInNewWindow(true);
remoteGoto.setFile(fileDesc);
txtLink.setAction(remoteGoto);
txtLink.setRectangle(rect);
page.getAnnotations().add(txtLink);

Steps to reproduce the bug

Upload this document.
appellatecourtorder.pdf

Compare page two from the original

Screen_Shot_2021-08-05_at_5 00 58_PM

With page two from the version now hosted on documentcloud:

Screen_Shot_2021-08-05_at_5 02 17_PM

The URL you were on:

https://www.documentcloud.org/documents/20417920-appellatecourtorder

@duckduckgrayduck duckduckgrayduck added bug Something isn't working some day labels Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working some day
Projects
None yet
Development

No branches or pull requests

1 participant