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

PDF file annotations (un-flattened) do not show #421

Closed
SevoMan opened this issue Nov 11, 2018 · 3 comments
Closed

PDF file annotations (un-flattened) do not show #421

SevoMan opened this issue Nov 11, 2018 · 3 comments

Comments

@SevoMan
Copy link

SevoMan commented Nov 11, 2018

When a PDF document is edited in another program (Adobe/Foxit/Edge), with annotations, text boxes, shapes, etc.. and saved... QuickLook will not show the annotations and instead shows the pre-annotation original file.

Then only time QuickLook will show these annotations is if the file is 'flattened'/made permanent. Windows thumbnails/explorer preview (and also the original Mac QuickLook) all show these unsaved annotations and so should QuickLook. Please fix. Excellent program otherwise.

@xupefei
Copy link
Member

xupefei commented Jan 6, 2019

The underlying PdfiumViewer does not support showing annotations. I don't know why but have no time to research into it ...

Any comment is appreciated.

@rabelux
Copy link
Member

rabelux commented Jan 7, 2021

@xupefei I tried digging into this issue and stumbled upon a few things.
First possible solution from stackoverflow is using following code snippet:

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);

Second approach is using the FPDF_ANNOT flag. The render()-function can take this flag as an input (found in PdfiumViewer/PdfiumViewer/PdfDocument.cs but you're using a different overload of this function PdfDocumentWrapper.Render(CurrentPage, factor) that I couldn't find in the library, so I don't where your functions comes from and whether it can handle this flag. Hope this helps.

@mooflu
Copy link
Contributor

mooflu commented Jan 9, 2021

The code passes an annotation flag here: https://github.com/QL-Win/QuickLook/blob/master/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfPageExtension.cs#L65

It's just that PdfiumViewer hasn't been updated in a while and the original author has stopped working on it. When I try https://github.com/frankhommers/PdfiumViewer and a more recent pdfium dll from here https://github.com/bblanchon/pdfium-binaries annotations show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants