Я использую управление winform для PDfiumViewer для отображения pdf-файлов. И, я добавил несколько аннотаций к pdf, но они не отображаются в элементе управления pdfviewer. Итак, как это можно добиться?Как показать аннотации в pdf с помощью pdfium viewer?
0
A
ответ
0
я был в состоянии решить эту проблему, используя следующий код:
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);
2
В PDFium имеется флаг FPDF_ANNOT, который может быть передан различным методам FPDF_RenderPage *. Возможно, код PDFiumViewer имеет тот же флаг.