|
ViewerPreferences Complete Reference
ViewerPreferences 可控制 PDF 檔案在支援的檢視器中如何呈現,以及部分預設列印設定如何初始化。目前 HotPDF library 支援 14 個 ViewerPreferences values,以及相關的 InitialZoom property
目前的資料型別
THPDFDirection = (LeftToRight, RightToLeft);
THPDFNonFullScreenPageMode = (
nfpmUseNone, nfpmUseOutlines, nfpmUseThumbs, nfpmUseOC, nfpmUseAttachments
);
THPDFPrintScaling = (psNone, psAppDefault);
THPDFDuplex = (dupSimplex, dupDuplexFlipShortEdge, dupDuplexFlipLongEdge);
THPDFPageBoundary = (pbMediaBox, pbCropBox, pbBleedBox, pbTrimBox, pbArtBox);
THPDFInitialZoom = (
FitNone, FitPage, FitWidth, FitHeight, FitBox, FitBoxWidth, FitBoxHeight,
Zoom50, Zoom75, Zoom100, Zoom125, Zoom150, Zoom200
);
THPDFViewerPreference = (
vpHideToolbar, vpHideMenubar, vpHideWindowUI, vpFitWindow, vpCenterWindow,
vpDisplayDocTitle, vpDirection, vpNonFullScreenPageMode, vpPrintScaling,
vpDuplex, vpPickTrayByPDFSize, vpNumCopies, vpPrintArea, vpPrintClip,
vpViewArea, vpViewClip
);
THPDFViewerPreferences = set of THPDFViewerPreference;
支援的 ViewerPreferences
| 選項 |
配套屬性 |
說明 |
| vpHideToolbar |
無 |
隱藏檢視器工具列 |
| vpHideMenubar |
無 |
隱藏檢視器選單列 |
| vpHideWindowUI |
無 |
隱藏捲軸與導覽控制項等 UI 元素 |
| vpFitWindow |
無 |
調整文件視窗大小,以符合第一個顯示的頁面 |
| vpCenterWindow |
無 |
把文件視窗置中於螢幕 |
| vpDisplayDocTitle |
Title |
在檢視器標題顯示文件標題而非檔名 |
| vpDirection |
Direction |
使用 LeftToRight 或 RightToLeft |
| vpNonFullScreenPageMode |
NonFullScreenPageMode |
選擇離開全螢幕模式後使用的頁面模式 |
| vpPrintScaling |
PrintScaling |
預設列印縮放請選擇 psNone 或 psAppDefault |
| vpDuplex |
Duplex |
選擇單面或雙面列印 |
| vpPickTrayByPDFSize |
無 |
依 PDF 頁面大小要求印表機選紙 |
| vpNumCopies |
NumCopies |
儲存建議的列印份數 |
| vpPrintArea |
PrintArea |
選擇列印轉譯使用的頁面邊界 |
| vpPrintClip |
PrintClip |
選擇列印裁切使用的頁面邊界 |
| vpViewArea |
ViewArea |
螢幕檢視區域使用的頁面邊界(PDF 1.4 12.2)。HotPDF v2.29.0 起可用 |
| vpViewClip |
ViewClip |
螢幕檢視裁切使用的頁面邊界(PDF 1.4 12.2)。HotPDF v2.29.0 起可用 |
配套屬性值
只有啟用相符 ViewerPreferences flag 時,這些 properties 才會寫入
| 屬性 |
值 |
| Direction |
LeftToRight, RightToLeft |
| NonFullScreenPageMode |
nfpmUseNone, nfpmUseOutlines, nfpmUseThumbs, nfpmUseOC, nfpmUseAttachments |
| PrintScaling |
psNone, psAppDefault |
| Duplex |
dupSimplex, dupDuplexFlipShortEdge, dupDuplexFlipLongEdge |
| PrintArea / PrintClip / ViewArea / ViewClip |
pbMediaBox, pbCropBox, pbBleedBox, pbTrimBox, pbArtBox |
InitialZoom 整合
InitialZoom 會補足 ViewerPreferences,控制檔案開啟時的初始頁面顯示模式
預設值:自 HotPDF v2.3.11 起,預設值為 FitHeight(PDF /FitV destination),因此產生的檔案開啟時每頁會符合 viewer 視窗高度。將 InitialZoom 設為 FitNone 可省略 OpenAction,讓 viewer fallback 到自己的預設 zoomFitHeight(PDF /FitV 目的地),讓產生的文件開啟時每一頁都符合檢視器視窗高度。把 InitialZoom 設為 FitNone
// Complete document presentation setup
HotPDF.ViewerPreferences := [vpFitWindow, vpCenterWindow, vpDisplayDocTitle];
HotPDF.InitialZoom := FitWidth;
// Technical document setup
HotPDF.ViewerPreferences := [vpDisplayDocTitle, vpPrintScaling];
HotPDF.InitialZoom := Zoom125;
// Presentation mode
HotPDF.ViewerPreferences := [vpFitWindow, vpHideToolbar, vpHideMenubar];
HotPDF.InitialZoom := FitPage;
實作範例
var
VPref: THPDFViewerPreferences;
begin
VPref := [vpFitWindow, vpCenterWindow, vpDisplayDocTitle];
if EnableDirection then
begin
Include(VPref, vpDirection);
HotPDF.Direction := RightToLeft;
end;
if EnablePrintScaling then
begin
Include(VPref, vpPrintScaling);
HotPDF.PrintScaling := psNone;
end;
HotPDF.ViewerPreferences := VPref;
HotPDF.InitialZoom := FitWidth;
end;
相容性注意事項
- Acrobat 與 Reader:通常提供最完整的 ViewerPreferences 功能支援
- 其他 Viewers:支援程度不一,因為這些值是 preferences,而不是硬性要求
- 優雅降級:符合規範的檢視器應安全忽略不支援的設定
Demo 應用程式
下列 demos 已與目前 library 支援同步:
- Demo\Delphi\ViewerPref
- Demo\CBuilder\ViewerPref
|