I am creating an application that takes an existing PDF, verifies if it is a PDF/A, and if not, it converts it from a PDF to a PDF/A. After it converts, I call the verification code one more time to ensure the conversion was successful. I’m hitting a PDF where it’s not a PDF/A, so I convert it. But when I run the verification after it’s complete, it returns the following error from PDFACompliance.GetPDFAErrorMessage:
tintTransform is different in Separations with the same colorant name
Because the GetErrorCount() is 1, my verification fails, though if I open the document in Acrobat, it does look like a PDF/A. Can you please explain what that error means, whether or not I should hard-code my verification to ignore that error, and whether there are other errors that I should also ignore when it comes to verifying if the document is a PDF/A?
Here is my code:
private static bool ConvertToPdfA(ref Document document)
{
try
{
using var pdfCompliance = new PDFACompliance(true, document.OutputFile, null, PDFACompliance.Conformance.e_Level2B, null, 10, false);
var tempOutput = document.OutputFile + “.tmp”;
pdfCompliance.SaveAs(tempOutput, false);
if (!IsPdfA(tempOutput))
throw new Exception(“Failed to convert to PDF/A”);
pdfCompliance.Dispose();
File.Delete(document.OutputFile);
File.Move(tempOutput,document.OutputFile);
return true;
}
catch (Exception e)
{
document.ErrorMessage = e.Message;
return false;
}
}
private static bool IsPdfA(string inputFile)
{
try
{
using var pdfCompliance = new PDFACompliance(false, inputFile, null, PDFACompliance.Conformance.e_Level2B, null, 10, false);
return pdfCompliance.GetErrorCount() == 0;
}
catch (Exception)
{
return false;
}
}