Created attachment 25180 [details] my input pdf I'm trying to convert this pdf(1.5) to pdf/a-3, but I'm getting a validation error(6.2.4.3) by VeraPDF: Specification: ISO 19005-3:2012, Clause: 6.2.4.3, Test number: 2 DeviceRGB shall only be used if a device independent DefaultRGB colour space has been set when the DeviceRGB colour space is used, or if the file has a PDF/A OutputIntent that contains an RGB destination profile. I used the following command: gswin64 -dPDFA=3 -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=1 -sColorConversionStrategy=UseDeviceIndependentColor -sOutputFile=output.pdf input.pdf I also tried this: gswin64 -dPDFA=3 -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=1 -sColorConversionStrategy=RGB -sOutputFile=output_filename.pdf -sOutputICCProfile="C:\Program Files\gs\gs10.02.1\iccprofiles\srgb.icc" -dOverrideICC=true PDFA_def.ps input.pdf - but that resulted in an additional error regarding the gray color space: "Specification: ISO 19005-3:2012, Clause: 6.2.4.3, Test number: 4 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 attached the file, I'm trying to convert for reproducibility. Link to my stackoverflow question: https://stackoverflow.com/questions/77746495/ghostscript-pdf-to-pdf-a-3-conversion-results-in-a-colorspace-validation-error-b Am I doing something wrong or is this a bug in 10.02.1?
(In reply to Thomas from comment #0) > gswin64 -dPDFA=3 -dBATCH -dNOPAUSE -sDEVICE=pdfwrite > -dPDFACompatibilityPolicy=1 -sColorConversionStrategy=RGB > -sOutputFile=output_filename.pdf -sOutputICCProfile="C:\Program > Files\gs\gs10.02.1\iccprofiles\srgb.icc" -dOverrideICC=true PDFA_def.ps > input.pdf > > - but that resulted in an additional error regarding the gray color space: You can't use an sRGB ICC profile for an RGB space. sRGB is not the same thing as RGB. Try using a real RGB ICC profile. You should not be using OverrideICC without specifying the default spaces, as described here: https://ghostscript.readthedocs.io/en/gs10.0.0/Use.html#doverrideicc You really shouldn't be using that anyway. I'll look into this when I have some time.
The problem is that 'UseDeviceIndependentColor' isn't transforming image colour spaces. If I use this command line (current HEAD of master): -sDEVICE=pdfwrite -o good.pdf -sColorConversionStrategy=RGB -dCompressPages=false -dWriteObjStms=false -dWriteXRefStm=false -dPDFA=3 --permit-file-read=/ghostpdl/iccprofiles/default_rgb.icc pdfa_def.ps bug707450.pdf with an appropriately modified pdfa_de.ps: % Define an ICC profile : /ICCProfile (/ghostpdl/iccprofiles/default_rgb.icc) % Customise def Then the resulting PDF file passes PDF/A-3b validation with VeraPDF 1.22.3. I'm altering this to an enhancement to the UseDeviceIndependentColor colour conversion strategy.
I managed to reproduce this with 10.03.0. Thanks you.
The problem is that the input file has three cases of images with an SMask. The SMask image *must* be in DeviceGray (the spec says so), but we can only use DeviceGray if we set ColorConversionStrategy to Gray, and embed a gray ICC profile in the OutputIntent. There seems to be no way to deal with this, and it seems to me it is an oversight in the PDF/A specification. The fact that the image is in DeviceGray isn't relevant to accurate colour reproduction since the gray levels are actual alpha values, so we should be permitted to use DeviceGray in this case. Anyway, since we aren't I've added code in this commit 4dcfae36bb4dcbc4ef3b5e5afc98bcde0d6b9ddc which will detect the condition, warn the user, and disable PDF/A output. Marking as fixed because the commit prevents production of a PDF/A which uses DeviceGray, we cannot 'fix' the incompatibility.
Am i correct, that the given file is not convertable to pdfa3 with ghostscript? I tried your command, where you mentioned, you were able to create a a3 file. -sDEVICE=pdfwrite -o good.pdf -sColorConversionStrategy=RGB -dCompressPages=false -dWriteObjStms=false -dWriteXRefStm=false -dPDFA=3 --permit-file-read=/ghostpdl/iccprofiles/default_rgb.icc pdfa_def.ps bug707450.pdf with the given file and ghostscript 10.03.1 on macos (via homebrew) and still cant get a pdfa3 file. > Detected SMask which must be in DeviceGray, but we are not converting to DeviceGray, reverting to normal PDF output. What does seem to work, ist a conversion to pdfa1 then pdfa3 1) -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -sColorConversionStrategy=UseDeviceIndependentColor -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=1 -sOutputFile=buga.pdf bug.pdf 2) first command with =UseDeviceIndependentColor on the file from 1) seems to run without errors and no validation error on 6.2.4.3
(In reply to Sascha from comment #5) > Am i correct, that the given file is not convertable to pdfa3 with > ghostscript? Oher people have raised the issue of SMask in PDF/A-2 and above and there is a clarification tech note from the PDFA organisation which contains a specific exemption for this case, allowing SMask images to be defined in DeviceGray. So the file can be converted to PDF/A using code built from the current HEAD of our Git repository (NOT any current release) and a suitable command line. > I tried your command, where you mentioned, you were able to create a a3 > file. > > -sDEVICE=pdfwrite -o good.pdf -sColorConversionStrategy=RGB > -dCompressPages=false -dWriteObjStms=false -dWriteXRefStm=false -dPDFA=3 > --permit-file-read=/ghostpdl/iccprofiles/default_rgb.icc pdfa_def.ps > bug707450.pdf > > with the given file and ghostscript 10.03.1 on macos (via homebrew) and > still cant get a pdfa3 file. > > > Detected SMask which must be in DeviceGray, but we are not converting to DeviceGray, reverting to normal PDF output. That's because you are now using 10.03.xx which includes the test for SMask, whereas at the time of that comment I was using 10.02.xx, because that was the release *at the time* and does not include that test. See my note in comment #4 and above regarding the use of SMask in a PDF/A-2 (or A-3) file. > What does seem to work, ist a conversion to pdfa1 then pdfa3 > > 1) -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE > -sColorConversionStrategy=UseDeviceIndependentColor -sDEVICE=pdfwrite > -dPDFACompatibilityPolicy=1 -sOutputFile=buga.pdf bug.pdf > > 2) first command with =UseDeviceIndependentColor on the file from 1) seems > to run without errors and no validation error on 6.2.4.3 That's because PDF/A-1 doesn't permit transparency, so the entire content is rendered to a bitmap and the that bitmap is stored inside a PDF file. Essentially you've turned the PDF into a picture of a PDF. I'd suggest you don't want to do that, but it's up to you.