0
私はpdfboxを使ってpdfファイルへのリンクを追加する機能を実装しました。pdfboxのPDActionRemoteGoToクラスを使ってPDFにコマンドを追加する方法は?
PDAnnotationLink txtLink = new PDAnnotationLink();
PDActionRemoteGoTo remoteGoto = new PDActionRemoteGoTo();
PDComplexFileSpecification fileDesc = new PDComplexFileSpecification();
file.setExecutable(true);
fileDesc.setFile(System.IO.Path.GetFileName(filePath));
fileDesc.setFileUnicode(System.IO.Path.GetFileName(filePath));
fileDesc.setFileDescription("");
remoteGoto.setOpenInNewWindow(true);
remoteGoto.setFile(fileDesc);
txtLink.setAction(remoteGoto);
txtLink.setRectangle(rect);
page.getAnnotations().add(txtLink);
を生成したリンクは、WindowsベースのPDFエディタで作業しているが、iOS用pdfviewerでは動作しません。以下は、私が使用していたコードです。私は手動でメモ帳、リンクの動作を使用して、/ S/GoToRに/ D [0 /フィット]コマンドを追加する場合
12 0 obj
<<
/Type /Annot
/Subtype /Link
/A 17 0 R
/Rect [1578.599 316.56006 1600.6244 326.62427]
>>
endobj
17 0 obj
<<
/S /GoToR
/NewWindow true
/F 20 0 R
>>
endobj
20 0 obj
<<
/Type /Filespec
/F (A201NORTHSOUTHSITEELEVATIONS.pdf)
/UF (A201NORTHSOUTHSITEELEVATIONS.pdf)
/Desc()
>>
endobj
そして:上記のコードを使用してPDFに入力されたコマンドです。 D =だから私はこれをpdfboxライブラリを使って追加します。また
PDPageDestination dest = new PDPageFitDestination();
dest.setPageNumber(0);
remoteGoto.setD(dest.getCOSObject());
、ちょうどCOSArray
を作成し、0とCOSName.getPDFName("Fit")
を追加し、setD()
に1つを渡します。