Search code examples
ghostscript

Rendering "pop up" and similar comments annotations in Ghostscript


I'm using Ghostscript to convert searchable PDFs to image PDFs so that they can be viewed using an imaging toolkit using a command line like this:

gswin32 -o c:\temp\output%d.png -r300 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dDOINTERPOLATE -dSAFER -sDEVICE=png16m c:\temp\test.pdf

If I add the -dDOPDFMARKS command line parameter it renders the annotation mark showing that there's an annotation but not the annotation text.

Does anyone know how to get Ghostscript to render annotation text? I've googled the life out of it without any luck.


Solution

  • Without seeing your PDF file I can't be sure but there are several possible reasons. Your annotation may be closed, ie not displaying anything when you open the PDF file. It may not have an appearance stream, Ghostscript does not manufacture appearance streams for all annotation types.

    Update

    What the provided PDF sample contains is 2 annotations: the first is the 'popup' annotation; the second is a text annotation.

    Popup annotations are basically interactive, because you can open and close them, move them around etc. However, Ghostscript doesn't support interactive elements. So what you get is the icon for the popup but you don't get the associated text annotation.

    There is no way currently to render this text with Ghostscript.