|
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
| 选项 |
配套属性 |
说明 |
| vpHideToolbar |
无 |
隐藏查看器工具栏 |
| vpHideMenubar |
无 |
隐藏查看器菜单栏 |
| vpHideWindowUI |
无 |
隐藏滚动条、导航控件等界面元素 |
| 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 起提供 |
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 目标),生成的文档打开时每页都适配查看器窗口高度。把 InitialZoom 设为 FitNone 可省略 OpenAction,让查看器回退到自己的默认缩放。
// 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
|