|
ViewerPreferences 完整参考
ViewerPreferences 允许控制 PDF 文档在支持它们的阅读器中的呈现方式,以及某些默认打印设置的初始化方式。当前 HotPDF 库支持 14 个 ViewerPreferences 值以及相关的 InitialZoom 属性
Current Data Types
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;
Supported ViewerPreferences
| Option |
Companion Property |
说明 |
| vpHideToolbar |
None |
Hide the viewer toolbar. |
| vpHideMenubar |
None |
Hide the viewer menu bar. |
| vpHideWindowUI |
None |
Hide UI elements such as scroll bars and navigation controls. |
| vpFitWindow |
None |
Resize the document window to fit the first displayed page. |
| vpCenterWindow |
None |
Center the document window on the screen. |
| vpDisplayDocTitle |
Title |
Display the document title instead of the file name in the viewer caption. |
| vpDirection |
Direction |
Store the predominant reading order using LeftToRight or RightToLeft. |
| vpNonFullScreenPageMode |
NonFullScreenPageMode |
Choose the page mode to use after leaving full-screen mode. |
| vpPrintScaling |
PrintScaling |
Choose psNone or psAppDefault for default print scaling. |
| vpDuplex |
Duplex |
Choose simplex or duplex printing behavior. |
| vpPickTrayByPDFSize |
None |
Request printer tray selection based on the PDF page size. |
| vpNumCopies |
NumCopies |
Store the suggested print copy count. |
| vpPrintArea |
PrintArea |
Select the page boundary used for print rendering. |
| vpPrintClip |
PrintClip |
Select the page boundary used for print clipping. |
| vpViewArea |
ViewArea |
Page boundary used for the on-screen view area (PDF 1.4 12.2). Available since HotPDF v2.29.0. |
| vpViewClip |
ViewClip |
Page boundary used for the on-screen view clipping (PDF 1.4 12.2). Available since HotPDF v2.29.0. |
Companion Property Values
这些属性只会在匹配的 ViewerPreferences 标志启用时写入
| 属性 |
Values |
| 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 Integration
InitialZoom 补充 ViewerPreferences,用于控制文档打开时的初始页面显示模式
默认值:自 HotPDF v2.3.11 起,默认值为 FitHeight(PDF /FitV destination),因此生成的文档会以每页适配阅读器窗口高度的方式打开。将 InitialZoom 设为 FitNone 可省略 OpenAction,并让阅读器回退到自身默认缩放。若需要打开时跳到命名目标,请使用 THotPDF.SetOpenNamedDestinationAction
// 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;
Implementation Example
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;
Compatibility Notes
- 通常 Adobe Reader/Acrobat 提供最完整的 ViewerPreferences 支持
- 其他阅读器:支持情况不同,因为这些值是偏好设置而非强制要求
- 合规阅读器应安全忽略不支持的设置
Demo Applications
以下 demo 已与当前库支持保持同步:
- Demo\Delphi\ViewerPref
- Demo\CBuilder\ViewerPref
|