private static PdfVersion GetPdfVersionForPdfA(PdfAConformanceLevel conformanceLevel) { PdfVersion version; switch (conformanceLevel.GetPart()) { case "1": { version = PdfVersion.PDF_1_4; break; } case "2": { version = PdfVersion.PDF_1_7; break; } case "3": { version = PdfVersion.PDF_1_7; break; } default: { version = PdfVersion.PDF_1_4; break; } } return(version); }
protected internal virtual void SetChecker(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel.GetPart()) { case "1": { checker = new PdfA1Checker(conformanceLevel); break; } case "2": { checker = new PdfA2Checker(conformanceLevel); break; } case "3": { checker = new PdfA3Checker(conformanceLevel); break; } } }
public virtual void InspectSignatures(String path) { Console.WriteLine("\n\n"); PdfDocument pdfDoc = new PdfDocument(new PdfReader(path)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, false); SignaturePermissions perms = null; SignatureUtil signUtil = new SignatureUtil(pdfDoc); IList <String> names = signUtil.GetSignatureNames(); Console.WriteLine(path); foreach (String name in names) { Console.Out.WriteLine("===== " + name + " ====="); perms = InspectSignature(pdfDoc, signUtil, form, name, perms); } PdfAConformanceLevel conformanceLevel = pdfDoc.GetReader().GetPdfAConformanceLevel(); string conformance = conformanceLevel == null ? string.Empty : conformanceLevel.GetConformance(); string part = conformanceLevel == null ? string.Empty : conformanceLevel.GetPart(); Console.Out.WriteLine($"Document conformance: {conformance}/{part}"); GetMetaInfo(pdfDoc); }
public Task <bool> IsPdfA2B(MemoryStream input) { PdfDocument inputPdf = new PdfDocument(new PdfReader(input)); try { PdfAConformanceLevel conformanceLevel = inputPdf.GetReader().GetPdfAConformanceLevel(); var conformance = conformanceLevel.GetConformance(); var part = conformanceLevel.GetPart(); return(Task.FromResult(conformance.Equals("B") && part.Equals("2"))); } catch (Exception) { return(Task.FromResult(false)); } finally { inputPdf.Close(); input.Dispose(); } }