您可以使用PostScript代碼段,使用特殊的pdfmark
運算符在Ghostscript幫助下將適當的DOCVIEW
設置插入到目標PDF中。
這裏是嵌入在一個文本文件爲例,my-pdf-docview-pdfmark.ps
:
[ /PageMode /UseOutlines % Display bookmarks upon opening the doc
%/PageMode /UseThumbs % Display thumbnails upon opening the doc
%/PageMode /FullScreen % Open the document in fullscreen mode
%/PageMode /None % Display neither bookmarks nor thumbnails upon opening
/Page 2 % Open document with page 2, not page 1!
%/View [ /XYZ null null null ]
% Go to specified page and retain same ...
% ... horizontal/vertical offset+zoom as current page
/View /Fit % Fit page to window
%/View /FitB % Fit visible part of page to window
%/View [/FitH 220] % Fit page width to window; 220 is distance ...
% ... of page origin from top of window
/DOCVIEW pdfmark
[ {Catalog} <<
/PageLayout /SinglePage
%/PageLayout /OneColumn
%/PageLayout /TwoColumnRight
%/PageLayout /TwoColumnLeft
>> /PUT pdfmark
注意,這是不是一個錯誤,只看到左方括號[
,但沒有一個關閉一個。 [
是一個運算符,它由最終關鍵字pdfmark
關閉。
上面的一些行未用初始%
字符評論以向您展示其他替代方案。
請注意,這可能不適用於所有用戶或所有觀衆。這些設置只是對觀衆的暗示和建議,觀衆可能會或可能不會尊重他們。此外,用戶可以覆蓋其查看器的配置並告訴它始終忽略這些提示,而是按用戶指定的方式打開所有PDF。
一旦你創建的上述文件,將其應用到PDF:
gs -o output.pdf \
-sDEVICE=pdfwrite \
my-pdf-docview-pdfmark.ps \
-f input.pdf