2017-02-09 485 views

回答

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代碼有可能在某處提供相同的標誌。