简体   繁体   English

使用Ghostscript创建Highlight PDF注释

[英]Create Highlight PDF annotations with Ghostscript

I have the following PostScript file containing a pdfmark to create a highlight annotation: 我有以下包含pdfmark的PostScript文件,用于创建突出显示注释:

%PS

/Courier 30 selectfont
15 15 moveto
(Test)show

[ /Rect [0 0 80 30]
/Subtype /Highlight
/Color [.8 .8 0]
/QuadPoints [10 40 90 40 10 10 90 10]
/Contents (Test annotation)
/ANN pdfmark

showpage

(Note that the coordinates of the /QuadPoints field are not in the order the specs define , as Adobe implements it differently .) (请注意, /QuadPoints字段的坐标不符合规范定义的顺序 ,因为Adobe的实现方式有所不同 。)

Ghostscript creates a PDF with an annotation from that, but there are two issues: Ghostscript创建一个带有注释的PDF,但是存在两个问题:

  1. It works in Adobe Reader and Okular, but it's not clickable in Evince. 它可在Adobe Reader和Okular中使用,但在Evince中不可单击。
  2. More important: The highlighted area isn't a rectangle but has rounded left and right edges, as can be seen from the following screenshot: 更为重要:高亮区域不是矩形,而是具有圆形的左右边缘,如以下屏幕截图所示:

    批注的屏幕截图

    Why is that and how can I get straight edges? 为什么会这样,我如何才能获得直线边缘?

You should start by looking at the content of the PDF file and seeing what Ghostscript (or more accurately the pdfwrite device) has put in there. 您应该先查看PDF文件的内容,然后查看其中放置了Ghostscript(或更准确地说是pdfwrite设备)的内容。 Posting an example PDF file to look at would be a sensible move too, and would also tell us which version of Ghostscript you are using. 发布示例PDF文件进行查看也是明智之举,并且还会告诉我们您使用的是哪个版本的Ghostscript。

BTW that header should be %!PS, you missed off the '!'. 顺便说一句,标题应该是%!PS,您错过了'!'。 Of course since its a comment it doesn't matter to the PostScript interpreter. 当然,由于它是注释,所以对PostScript解释器没有关系。

Now here's the output from Adobe Acrobat Distiller for the annotation, using the code in your question: 现在,这是使用问题代码的Adobe Acrobat Distiller输出的注释:

1 0 obj
<</Type/Annot/Subtype/Highlight/Rect[0 0 80 30]/C[.8 .8 0]/QuadPoints[10 40 90 40 10 10 90 10]/Contents(Test annotation)>>
endobj

And here's the same from Ghostscript's pdfwrite device: 这与Ghostscript的pdfwrite设备相同:

8 0 obj
<</Type/Annot
/Rect [0 0 80 30]
/C [0.8 0.8 0]
/QuadPoints [10 40 90 40 10 10 90 10]
/Contents(Test annotation)
/Subtype/Highlight>>endobj

These are essentially identical. 这些基本上是相同的。

So to answer your questions: 因此,回答您的问题:

  1. If it works in Acrobat, then perhaps you should ask the Evince developers this question. 如果它在Acrobat中有效,那么您也许应该问Evince开发人员这个问题。

  2. The rounded edges are drawn by the application which reads the PDF annotation. 圆形边缘由读取PDF注释的应用程序绘制。 Since Acrobat draws them that way, everyone else does the same (including Ghostscript's PDF interpreter). 由于Acrobat以这种方式绘制它们,因此其他所有人也都这样做(包括Ghostscript的PDF解释器)。 If you don't like it you will have to change the viewing application. 如果您不喜欢它,则必须更改查看应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM