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.
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.