private void ConvertToPdfa(Job job) { if (job.Profile.OutputFormat.IsPdfA()) { var sourcePdf = job.IntermediatePdfFile; if (string.IsNullOrEmpty(sourcePdf)) { return; } var targetPdf = AddTailToFile(sourcePdf, "_pdfa"); var version = DeterminePdfVersionAsEnum(job.Profile); var writerProperties = new WriterProperties(); writerProperties.SetPdfVersion(version); byte[] resource; //Set ICC Profile according to the color model switch (job.Profile.PdfSettings.ColorModel) { case ColorModel.Cmyk: resource = GhostscriptResources.WebCoatedFOGRA28; break; case ColorModel.Gray: resource = GhostscriptResources.ISOcoated_v2_grey1c_bas; break; default: resource = GhostscriptResources.eciRGB_v2; break; } try { using (var icc = new MemoryStream(resource)) { var document = new PdfADocument(new PdfWriter(targetPdf, writerProperties), GetConformLevel(job.Profile.OutputFormat), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc)); document.SetTagged(); var toCopyDoc = new PdfDocument(new PdfReader(sourcePdf)); toCopyDoc.CopyPagesTo(1, toCopyDoc.GetNumberOfPages(), document); var metaData = XMPMetaFactory.ParseFromBuffer(toCopyDoc.GetXmpMetadata()); document.SetXmpMetadata(metaData); toCopyDoc.Close(); document.Close(); File.Delete(sourcePdf); job.IntermediatePdfFile = targetPdf; } } catch (PdfAConformanceException ex) { throw new ProcessingException("One of the used pdfs does not conform to the PDF-A specification", ErrorCode.Processing_ConformanceMismatch, ex); } } }