Tham chiếu đầy đủ ViewerPreferences

ViewerPreferences cho phép bạn kiểm soát cách tài liệu PDF được trình bày trong các trình xem hỗ trợ và cách một số thiết lập in mặc định được khởi tạo. Thư viện HotPDF hiện hỗ trợ 14 giá trị ViewerPreferences cùng thuộc tính InitialZoom liên quan

Các kiểu dữ liệu hiện tại

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 được hỗ trợ

Tùy chọn Thuộc tính đi kèm Mô tả
vpHideToolbar None Ẩn thanh công cụ của trình xem
vpHideMenubar None Ẩn thanh menu của trình xem
vpHideWindowUI None Ẩn các thành phần giao diện như thanh cuộn và điều khiển điều hướng
vpFitWindow None Đổi kích thước cửa sổ tài liệu để vừa trang đầu tiên được hiển thị
vpCenterWindow None Căn giữa cửa sổ tài liệu trên màn hình
vpDisplayDocTitle Title Hiển thị tiêu đề tài liệu thay cho tên tệp trong tiêu đề cửa sổ của trình xem
vpDirection Direction Lưu trật tự đọc chủ đạo bằng LeftToRight hoặc RightToLeft
vpNonFullScreenPageMode NonFullScreenPageMode Chọn chế độ trang sẽ dùng sau khi rời chế độ toàn màn hình
vpPrintScaling PrintScaling Chọn psNone hoặc psAppDefault cho tỷ lệ in mặc định
vpDuplex Duplex Chọn hành vi in một mặt hoặc hai mặt
vpPickTrayByPDFSize None Yêu cầu chọn khay in dựa trên kích thước trang PDF
vpNumCopies NumCopies Lưu số bản in được gợi ý
vpPrintArea PrintArea Chọn biên trang dùng cho kết xuất in
vpPrintClip PrintClip Chọn biên trang dùng cho cắt xén khi in
vpViewArea ViewArea Biên trang dùng cho vùng xem trên màn hình (PDF 1.4 12.2). Có từ HotPDF v2.29.0
vpViewClip ViewClip Biên trang dùng cho việc cắt xén vùng xem trên màn hình (PDF 1.4 12.2). Có từ HotPDF v2.29.0

Giá trị thuộc tính đi kèm

Các thuộc tính này chỉ được ghi khi cờ ViewerPreferences tương ứng được bật

Thuộc tính Giá trị
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

Tích hợp InitialZoom

InitialZoom bổ trợ cho ViewerPreferences bằng cách điều khiển chế độ hiển thị trang ban đầu khi tài liệu được mở

Mặc định: Từ HotPDF v2.3.11, giá trị mặc định là FitHeight (đích PDF /FitV), nên tài liệu tạo ra sẽ mở với mỗi trang vừa theo chiều cao cửa sổ của trình xem. Đặt InitialZoom thành FitNone để bỏ qua OpenAction và để trình xem tự dùng mức zoom mặc định của nó

// 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;

Ghi chú tương thích

  • Adobe Reader/Acrobat: Thường có hỗ trợ ViewerPreferences đầy đủ nhất
  • Các trình xem khác: Mức hỗ trợ thay đổi vì các giá trị này chỉ là tùy chọn, không phải yêu cầu cứng
  • Suy giảm an toàn: Các thiết lập không được hỗ trợ nên bị bỏ qua an toàn bởi các trình xem tuân thủ

Ứng dụng demo

Các demo sau được đồng bộ với hỗ trợ hiện tại của thư viện

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