1

I try to annotate PDF-files with Ghostscript on Windows.

It works, but sometimes it returns error messages and the application of an annotation fails.

Can anyone tell what this error message actually means?

Here is a screenshot of the error message:

The command I used in this case:

"C:\Program Files (x86)\gs\gs9.10\bin\gswin32.exe" -o ./work/result/2530
902.pdf  -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress  ./work/result/2530902_b.pdf
./ann/2530902.txt
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345

1 Answers1

1

I'll update my answer accordingly, if you provide answers to the questions further below. Otherwise, I'll delete it again.

As the first guess, the /syntaxerror in -file- part of the screenshot suggests that your PDF file indeed contains a syntax error. I can only tell you...

  • ...which syntax error exactly,
  • ...whether this error could potentially be repaired/fixed,

...if you provide access to the PDF file for me (or anybody else).

The general method of using Ghostscript to add annotations to an existing PDF file is described here:

The command's structure has to be as the following (example tailored to the 32bit Windows environment):

gswin32c.exe                                      ^
  -o output.pdf                                   ^
  -sDEVICE=pdfwrite                               ^
   [...other settings...]                         ^
  -c "...PostScript code to add annotation(s)..." ^
  -f input.pdf

Please take good note of the following:

  1. there may be multiple occurrences of the -c parameter
  2. the existence of the -c parameter followed by some code in quotes;
  3. the order of the -c (for command) and -f (for file) parameters.

The -c "..." part can be replaced by a simple text file containing the content of the respective commands. But there is a strict syntax for annotation that needs to be respected.

I'm not absolutely sure you can change the order of the two parameters in all Ghostscript versions. (The above link shows it could be done at a time, though.) Try to change the order of the parameters and see if it fixes the problem.


Here are my questions:

  1. Can you provide (a link to) the PDF file resulting in the error message of the screenshot so I can check its syntax?

  2. Can you please provide the contents of your file ./ann/2530902.txt so I can check it for correctness?

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • Thank you. These documents are confidential so I can't give them to you :( and I can't generate test document. – Vesa Ala-Hakula Jan 14 '15 at 13:45
  • @VesaAla-Hakula: But surely the content of `./ann/2530902.txt` is not confidential? If there *are* confidential snippets in there (like the text of the annotation), you could easily replace it with some random strings, no?!? – Kurt Pfeifle Jan 14 '15 at 14:42