Java?pdf文件書簽承前縮放驗證的設(shè)置方法
1,什么是書簽承前縮放?

換句話來說
設(shè)置了承前縮放,當(dāng)你手動將page4縮放到145%,然后點擊書簽1,書簽1定位到的page1的縮放比例也是145%
2,如何設(shè)置書簽承前縮放?
使用工具:

承前縮放書簽設(shè)置:

其他類型書簽設(shè)置:

3,代碼
3.1 書簽結(jié)構(gòu):

3.2 代碼
import com.aspose.pdf.*;
public class bookmark {
public static void main(String[] args) {
// Open document
Document pdfDocument = new Document("D:\\chromeDownload\\測試版2.pdf");
OutlineCollection outlines = pdfDocument.getOutlines();
for (OutlineItemCollection outlineItem : (Iterable<OutlineItemCollection>) outlines) {
double soureceZoom = -1;
if (outlineItem.getDestination() != null) {
soureceZoom = getAppointmentZoom(outlineItem.getDestination());
} else if (outlineItem.getAction() != null) {
soureceZoom = getAppointmentZoom(outlineItem.getAction());
}
if(soureceZoom == -1){
System.out.println("書簽必須承前縮放,書簽名:" + outlineItem.getTitle() + ",縮放因子: " + soureceZoom);
// System.out.println("Title : " + outlineItem.getTitle() + ",縮放因子: " + soureceZoom);
if (outlineItem.size()>0){
checkBookmark(outlineItem);
}
}
private static void checkBookmark(OutlineItemCollection Outlines) {
private static double getAppointmentZoom(IAppointment appointment) {
if (appointment instanceof XYZExplicitDestination) {
XYZExplicitDestination destination = (XYZExplicitDestination) appointment;
return destination.getZoom();
} else if (appointment instanceof GoToAction) {
GoToAction goToAction = (GoToAction) appointment;
if (goToAction.getDestination() instanceof XYZExplicitDestination) {
XYZExplicitDestination destination = (XYZExplicitDestination) goToAction.getDestination();
return destination.getZoom();
} else if (appointment instanceof GoToRemoteAction) {
GoToRemoteAction goToRemoteAction = (GoToRemoteAction) appointment;
if (goToRemoteAction.getDestination() instanceof XYZExplicitDestination) {
XYZExplicitDestination destination = (XYZExplicitDestination) goToRemoteAction.getDestination();
return -1;
}3.3 控制臺輸出:

注意:承前縮放的因子為 0;
4,書簽的xml文件導(dǎo)出
4.1 代碼
import com.aspose.pdf.Document;
import com.aspose.pdf.facades.PdfBookmarkEditor;
import java.io.FileNotFoundException;
public class AsposeTest {
public static void main(String[] args) throws FileNotFoundException {
Document document6 = new Document("D:\\測試版2.pdf");
exportBookmarksToXML(document6);
}
public static void exportBookmarksToXML(Document document) throws FileNotFoundException {
PdfBookmarkEditor pdfBookmarkEditor = new PdfBookmarkEditor();
pdfBookmarkEditor.bindPdf(document);
pdfBookmarkEditor.exportBookmarksToXML("D:\\測試版2.xml");
pdfBookmarkEditor.getDocument().save();
}4.2 導(dǎo)出文件:
<?xml version="1.0" encoding="iso_8859_1"?> <Bookmark> <Title Open="True">目录縮放到頁面級別 <Title Page="2 XYZ 71 769 0" Action="GoTo" Open="True">3.2.S.7 稳定性承前縮放 <Title>3.2.S.7.1 稳定性总结</Title>實際大小 <Title Page="5 FitBH 842" Action="GoTo">3.2.S.7.2 上市后稳定性方案和稳定性承诺</Title>適合可見 <Title Page="8 XYZ 71 523 0" Action="GoTo">3.2.S.7.3 稳定性数据</Title>承前縮放 </Title> </Title> <Title Page="1 XYZ 0 842 0" Action="GoTo" Open="False">表目录</Title>承前縮放 <Title Page="1 XYZ 0 842 0" Action="GoTo" Open="False">图目录</Title>承前縮放 </Bookmark>
aspose.pdf 官網(wǎng)指路 : https://docs.aspose.com/pdf/java/get-update-and-expand-bookmark/
到此這篇關(guān)于Java pdf文件書簽承前縮放驗證的文章就介紹到這了,更多相關(guān)Java 書簽承前縮放驗證內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
淺談java線程中生產(chǎn)者與消費(fèi)者的問題
下面小編就為大家?guī)硪黄獪\談java線程中生產(chǎn)者與消費(fèi)者的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07
Springboot讀取templates文件html代碼實例
這篇文章主要介紹了Springboot讀取templates文件html代碼實例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-04-04
在java中 利用匿名內(nèi)部類進(jìn)行較簡潔的雙括弧初始化的方法
本篇文章小編將為大家介紹,關(guān)于在java中 利用匿名內(nèi)部類進(jìn)行較簡潔的雙括弧初始化的方法,有需要的朋友可以參考一下2013-04-04
關(guān)于spring.factories失效原因分析及解決
這篇文章主要介紹了關(guān)于spring.factories失效原因分析及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07
通過java備份恢復(fù)mysql數(shù)據(jù)庫的實現(xiàn)代碼
這篇文章主要介紹了如何通過java備份恢復(fù)mysql數(shù)據(jù)庫,其實一般情況下通過bat或sh就可以,這里主要是介紹了java的實現(xiàn)思路,喜歡的朋友可以參考下2013-09-09
Spring?Data?JPA查詢方式及方法名查詢規(guī)則介紹
這篇文章主要介紹了Spring?Data?JPA查詢方式及方法名查詢規(guī)則,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-11-11

