ViewerPreferences Complete Reference

ViewerPreferences를 사용하면 이를 지원하는 viewer에서 PDF document가 표시되는 방식과 일부 default print setting이 초기화되는 방식을 제어할 수 있습니다. 현재 HotPDF library는 14개의 ViewerPreferences 값과 관련 InitialZoom property를 지원합니다

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 속성 설명
vpHideToolbar 없음 Hide the viewer toolbar.
vpHideMenubar 없음 Hide the viewer menu bar.
vpHideWindowUI 없음 Hide UI elements such as scroll bars and navigation controls.
vpFitWindow 없음 Resize the document window to fit the first displayed page.
vpCenterWindow 없음 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 없음 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

이 property들은 matching ViewerPreferences flag가 enabled일 때만 작성됩니다

Property 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은 문서가 열릴 때 initial page display mode를 제어하여 ViewerPreferences를 보완합니다

기본값: HotPDF v2.3.11부터 기본값은 FitHeight(PDF /FitV destination)이므로 생성된 문서는 각 page가 viewer window height에 맞춰 열린 상태가 됩니다. OpenAction을 생략하고 viewer 자체 default zoom으로 fallback하게 하려면 InitialZoomFitNone으로 설정하십시오

// 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 support를 제공합니다
  • 기타 viewer: 이 값들은 hard requirement가 아니라 preference이므로 support가 달라질 수 있습니다
  • 우아한 성능 저하: 지원되지 않는 setting은 conforming viewer에서 안전하게 무시되어야 합니다

Demo Applications

다음 demo는 현재 library support와 동기화되어 있습니다

  • Demo\Delphi\ViewerPref
  • Demo\CBuilder\ViewerPref