-1

I searched for an answer but all I could find is how to convert pdf to pdf/a which is what I'm already doing. Now I need to find if the pdf is converted to prevent unnecessary second conversion. Right now I'm using Aspose to check if the pdf is converted but it's not always working correctly. Or maybe there's a different approach with either pdfbox or itext?

Thanks in advance for all the help.

nvko
  • 93
  • 1
  • 3
  • 6

1 Answers1

4

Ghostscript isn't a validation tool, it won't tell you if a PDF file is a PDF/a file. Not least because Ghostscript doesn't care.

[edited in answer to the comment below]

You have not specified a ColorConversionStrategy, specifying ProcessColorModel is not sufficient (and indeed not required). For PDF/A you (generally) will need to supply a ColorConversionStrategy unless you know for absolute certain your input file exclusively uses device independent colour spaces.

Your command line dos not appear to include a pdfa_def.ps input file. This file is important (and you must modify it appropriately), if you don't supply this, or equivalent programming, then your PDF/A file will not include an OutputIntent and, if it uses any device colour space, will not be valid.

Don't (really, seriously, don't) use -dNOSAFER. For PDF input there shouldn't be any need to do this and it's opening you up to security vulnerabilities.

Your command line includes -c -quit which is incorrect and should cause an error. You really mean -c quit and you don't need to do that anyway. Just leave it out.

The documentation on creating a PDF/A file can be found online here or in ghostpdl/doc/VectorDevices.htm#PDFA Note the 4th bullet point;

Specify a PDF/A definition file before running the input document.

halfer
  • 19,824
  • 17
  • 99
  • 186
KenS
  • 30,202
  • 3
  • 34
  • 51
  • Yup, I just checked out VeraPDF. But I can't make it work with gs, there are always some validation errors when I create PDF/A-3b with Ghostscript. For example: "DeviceGray shall only be used if a device independent DefaultGray colour space has been set when the DeviceGray colour space is used,or if a PDF/A OutputIntent is present" I use this command: gswin64c -dNOSAFER -sDEVICE=pdfwrite -dPDFA=3 -sProcessColorModel=DeviceRGB -dNOPAUSE -dBATCH -dPDFACompatibilityPolicy=1 -sOutputFile="path to testPdfa.pdf" "path to test.pdf" -c -quit – nvko Apr 01 '20 at 15:39
  • My response is too long for a comment so I've edited the answer above instead. – KenS Apr 01 '20 at 16:01