我想找到一種方法如何在具有雜色背景的 PDF 頁面上添加疊加頁碼。問題是,如果我使用這樣的常用方法:
(頁數.ps)
globaldict
/MyPageCount 1 put
<<
/EndPage
{
exch pop 0 eq dup
{
/Helvetica 12 selectfont
MyPageCount =string
cvs dup stringwidth pop
currentpagedevice
/PageSize get 0 get exch
sub 460 sub 810
moveto show
globaldict
/MyPageCount MyPageCount 1 add put
} if
} bind
>> setpagedevice
然后gs -dNOSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -o output.pdf -sDEVICE=pdfwrite -f pagecount.ps input.pdf
它可以作業,但是由于頁面上的背景雜亂無章,以前在空白頁面上看到的頁碼現在幾乎看不到了。
所以我想在數字周圍畫一些白色的小基板,以掩蓋它們在頁面上占據的區域,但數字本身是可見的。
一個想法是使用注釋\Rect:
(pagecount.ps,最初取自
globaldict
/MyPageCount 16 put
<<
/EndPage
{
exch pop 0 eq dup
{
/Helvetica 12 selectfont
MyPageCount =string
cvs
dup stringwidth pop
currentpagedevice
/PageSize get 0 get exch
sub 460 sub 710
moveto % move to text drawing position
% lines new to pagecount.ps
dup % duplicate string on the stack
true charpath flattenpath pathbbox % consume the string and put coordinates of bounding box to stack
newpath % start drawing bounding box
3 index 3 index moveto % copy llx and lly to the top of stack and move to them
3 index 1 index lineto % copy llx and ury to the top of stack and draw line to them
1 index 1 index lineto % copy urx and ury to the top of stack and draw line to them
1 index 3 index lineto % copy urx and lly to the top of stack and draw line to them
3 index 3 index lineto % copy llx and lly to the top of stack and draw line to them
closepath
% remove coordinates of bounding box from stack
gsave
1 0 0 setrgbcolor
fill grestore 1 0 0 setrgbcolor
5 setlinewidth stroke
pop pop pop pop
0 0 0 setrgbcolor
dup stringwidth pop
currentpagedevice
/PageSize get 0 get exch
sub 460 sub 710
moveto
% end of new lines
show
globaldict
/MyPageCount MyPageCount 1 add put
} if
} bind
>> setpagedevice
第二種是編號方案,其中數字具有輔助文本,并且都具有模糊的背景。
看:
userdict begin
%%EndProlog
%
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/465196.html
下一篇:C#在物件內創建相關專案的物件
