/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>Stream</CODE> the writer has to write to. * @param conformanceLevel PDF/A conformance level of a new PDF document * @return a new <CODE>PdfWriter</CODE> * @throws DocumentException on error */ public static PdfAWriter GetInstance(Document document, Stream os, PdfAConformanceLevel conformanceLevel) { PdfDocument pdf = new PdfDocument(); document.AddDocListener(pdf); PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel); pdf.AddWriter(writer); return writer; }
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); }
/** * Adds information about the PDF/A conformance level to the XMP metadata. * * @param conformanceLevel * @throws IOException */ private void AddRdfDescription(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_1B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_2B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PdfAConformanceLevel.PDF_A_3A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_3B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_3U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PdfAConformanceLevel.ZUGFeRD: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); IXmpMeta taggedExtensionMeta = XmpMetaFactory.ParseFromString(zugferdExtension); XmpUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false); break; default: break; } if (writer.IsTagged()) { IXmpMeta taggedExtensionMeta = XmpMetaFactory.ParseFromString(pdfUaExtension); XmpUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false); } }
public ZugferdProperties(iText.Zugferd.ZugferdProperties other) { this.metaInfo = other.metaInfo; this.zugferdConformanceLevel = other.zugferdConformanceLevel; this.pdfaConformanceLevel = other.pdfaConformanceLevel; this.pdfOutputIntent = other.pdfOutputIntent; }
public static void Convert(string inputPath, string outputPath, string pdfAConformanceLevel) { _inputFilePath = inputPath; _pdfaConformanceLevel = (PdfAConformanceLevel)Enum.Parse(typeof(PdfAConformanceLevel), pdfAConformanceLevel); PdfReader reader = new PdfReader(_inputFilePath); Document doc = new Document(); using (MemoryStream ms = new MemoryStream()) { SetPdfAConformance(reader, doc, ms); doc.Close(); reader.Close(); using (FileStream fs = new FileStream(outputPath, FileMode.Create)) { // this is the part stumping me; I need to use a PdfStamper to write // out some values to fields on the form AFTER the pages are removed. // This works, but there doesn't seem to be a form on the copied page... var stamper = new PdfStamper(new PdfReader(ms.ToArray()), fs) { FormFlattening = true }; // write out fields here... stamper.SetFullCompression(); stamper.Close(); } } }
/** * @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel) */ public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; switch (this.conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: pdfAChecker = new PdfA1Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: pdfAChecker = new PdfA2Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: pdfAChecker = new PdfA3Checker(conformanceLevel); break; default: pdfAChecker = new PdfA1Checker(conformanceLevel); break; } }
public PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties) : base(reader, writer, properties) { byte[] existingXmpMetadata = GetXmpMetadata(); if (existingXmpMetadata == null) { throw new PdfAConformanceException(PdfAConformanceException.DocumentToReadFromShallBeAPdfAConformantFileWithValidXmpMetadata ); } XMPMeta meta; try { meta = XMPMetaFactory.ParseFromBuffer(existingXmpMetadata); } catch (XMPException) { throw new PdfAConformanceException(PdfAConformanceException.DocumentToReadFromShallBeAPdfAConformantFileWithValidXmpMetadata ); } PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.GetConformanceLevel(meta); if (conformanceLevel == null) { throw new PdfAConformanceException(PdfAConformanceException.DocumentToReadFromShallBeAPdfAConformantFileWithValidXmpMetadata ); } SetChecker(conformanceLevel); }
/** * @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel) */ virtual public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; switch (this.conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: pdfAChecker = new PdfA1Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: pdfAChecker = new PdfA2Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: pdfAChecker = new PdfA3Checker(conformanceLevel); break; case PdfAConformanceLevel.ZUGFeRD: case PdfAConformanceLevel.ZUGFeRDComfort: case PdfAConformanceLevel.ZUGFeRDBasic: case PdfAConformanceLevel.ZUGFeRDExtended: pdfAChecker = new ZugferdChecker(conformanceLevel); break; default: pdfAChecker = new PdfA1Checker(conformanceLevel); break; } }
/** * * @param writer * @param conformanceLevel */ public static void SetPdfVersion(PdfWriter writer, PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: writer.PdfVersion = PdfWriter.VERSION_1_4; break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: writer.PdfVersion = PdfWriter.VERSION_1_7; break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: writer.PdfVersion = PdfWriter.VERSION_1_7; break; default: writer.PdfVersion = PdfWriter.VERSION_1_4; break; } }
/** * @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel) */ virtual public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; switch(this.conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: pdfAChecker = new PdfA1Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: pdfAChecker = new PdfA2Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: pdfAChecker = new PdfA3Checker(conformanceLevel); break; case PdfAConformanceLevel.ZUGFeRD: case PdfAConformanceLevel.ZUGFeRDComfort: case PdfAConformanceLevel.ZUGFeRDBasic: case PdfAConformanceLevel.ZUGFeRDExtended: pdfAChecker = new ZugferdChecker(conformanceLevel); break; default: pdfAChecker = new PdfA1Checker(conformanceLevel); break; } }
/// <summary>Constructs a new PdfADocument for writing purposes, i.e.</summary> /// <remarks> /// Constructs a new PdfADocument for writing purposes, i.e. from scratch. A /// PDF/A file has a conformance level, and must have an explicit output /// intent. /// </remarks> /// <param name="writer"> /// the /// <see cref="iText.Kernel.Pdf.PdfWriter"/> /// object to write to /// </param> /// <param name="conformanceLevel">the generation and strictness level of the PDF/A that must be followed.</param> /// <param name="outputIntent"> /// a /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/> /// </param> /// <param name="properties"> /// a /// <see cref="iText.Kernel.Pdf.DocumentProperties"/> /// </param> public PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent, DocumentProperties properties) : base(writer, properties) { SetChecker(conformanceLevel); AddOutputIntent(outputIntent); }
/// <summary>Open a PDF/A document in stamping mode.</summary> /// <param name="reader">PDF reader.</param> /// <param name="writer">PDF writer.</param> /// <param name="properties">properties of the stamping process</param> public PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties) : base(reader, writer, properties) { byte[] existingXmpMetadata = GetXmpMetadata(); if (existingXmpMetadata == null) { throw new PdfAConformanceException(PdfAConformanceException.DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA ); } XMPMeta meta; try { meta = XMPMetaFactory.ParseFromBuffer(existingXmpMetadata); } catch (XMPException) { throw new PdfAConformanceException(PdfAConformanceException.DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA ); } PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.GetConformanceLevel(meta); if (conformanceLevel == null) { throw new PdfAConformanceException(PdfAConformanceException.DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA ); } SetChecker(conformanceLevel); }
/** * Creates new PdfStamperImp. * @param reader reads the PDF * @param os the output destination * @param pdfVersion the new pdf version or '\0' to keep the same version as the original document * @param append * @param conformanceLevel PDF/A conformance level of a new PDF document * @throws DocumentException on error * @throws IOException */ internal PdfAStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append, PdfAConformanceLevel conformanceLevel) : base(reader, os, pdfVersion, append) { ((IPdfAConformance)pdfIsoConformance).SetConformanceLevel(conformanceLevel); PdfAWriter.SetPdfVersion(this, conformanceLevel); ReadPdfAInfo(); }
/** * Creates and XMP writer that adds info about the PDF/A conformance level. * @param os * @param info * @param conformanceLevel * @throws IOException */ public PdfAXmpWriter(Stream os, PdfDictionary info, PdfAConformanceLevel conformanceLevel) : base(os, info) { try { AddRdfDescription(conformanceLevel); } catch (XmpException xmpExc) { throw new IOException(xmpExc.Message); } }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>Stream</CODE> the writer has to write to. * @param conformanceLevel PDF/A conformance level of a new PDF document * @return a new <CODE>PdfWriter</CODE> * @throws DocumentException on error */ public static PdfAWriter GetInstance(Document document, Stream os, PdfAConformanceLevel conformanceLevel) { PdfDocument pdf = new PdfDocument(); document.AddDocListener(pdf); PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel); pdf.AddWriter(writer); return(writer); }
/** * Creates and XMP writer that adds info about the PDF/A conformance level. * * @param os * @param info * @param conformanceLevel * @throws IOException */ public PdfAXmpWriter(Stream os, IDictionary <String, String> info, PdfAConformanceLevel conformanceLevel, PdfWriter writer) : base(os, info) { this.writer = writer; try { AddRdfDescription(conformanceLevel); } catch (XmpException xmpExc) { throw new IOException(xmpExc.Message); } }
/* (non-Javadoc) * @see com.itextpdf.pdfa.PdfADocument#setChecker(com.itextpdf.kernel.pdf.PdfAConformanceLevel) */ protected override void SetChecker(PdfAConformanceLevel conformanceLevel) { if (!conformanceLevel.Equals(PdfAConformanceLevel.PDF_A_3B)) { ILog logger = LogManager.GetLogger(typeof(iText.Zugferd.ZugferdDocument)); logger.Warn(ZugferdLogMessageConstant.WRONG_OR_NO_CONFORMANCE_LEVEL); checker = new ZugferdChecker(PdfAConformanceLevel.PDF_A_3B); } else { checker = new ZugferdChecker(conformanceLevel); } }
/** * Adds information about the PDF/A conformance level to the XMP metadata. * @param conformanceLevel * @throws IOException */ private void AddRdfDescription(PdfAConformanceLevel conformanceLevel) { PdfASchema schema = new PdfASchema(); switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: schema.AddPart("1"); schema.AddConformance("A"); break; case PdfAConformanceLevel.PDF_A_1B: schema.AddPart("1"); schema.AddConformance("B"); break; case PdfAConformanceLevel.PDF_A_2A: schema.AddPart("2"); schema.AddConformance("A"); break; case PdfAConformanceLevel.PDF_A_2B: schema.AddPart("2"); schema.AddConformance("B"); break; case PdfAConformanceLevel.PDF_A_2U: schema.AddPart("2"); schema.AddConformance("U"); break; case PdfAConformanceLevel.PDF_A_3A: schema.AddPart("3"); schema.AddConformance("A"); break; case PdfAConformanceLevel.PDF_A_3B: schema.AddPart("3"); schema.AddConformance("B"); break; case PdfAConformanceLevel.PDF_A_3U: schema.AddPart("3"); schema.AddConformance("U"); break; default: break; } base.AddRdfDescription(schema); }
private static PdfAConformanceLevel GetPdfAConformanceLevel(ZugferdProperties properties) { PdfAConformanceLevel local = properties.pdfaConformanceLevel; if (local != null) { return(local); } else { LogManager.GetLogger(typeof(ZugferdDocument)).Warn(ZugferdLogMessageConstant.WRONG_OR_NO_CONFORMANCE_LEVEL); return(PdfAConformanceLevel.PDF_A_3B); } }
/** * Adds information about the PDF/A conformance level to the XMP metadata. * @param conformanceLevel * @throws IOException */ private void AddRdfDescription(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_1B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_2B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PdfAConformanceLevel.PDF_A_3A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_3B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_3U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; default: break; } }
public virtual void PdfA1DocWithPdfA1CheckBoxFieldTest() { String name = "pdfA1DocWithPdfA1CheckBoxField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1CheckBoxField.pdf"; Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); form.AddField(PdfFormField.CreateCheckBox(pdfDoc, new Rectangle(36, 726, 20, 20), "checkBox", "1", PdfFormField .TYPE_STAR, conformanceLevel)); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
public virtual void PdfA1DocWithPdfA1PushButtonFieldTest() { String name = "pdfA1DocWithPdfA1PushButtonField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1PushButtonField.pdf"; PdfFont fontFreeSans = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); form.AddField(PdfFormField.CreatePushButton(pdfDoc, new Rectangle(36, 526, 100, 20), "push button", "Push" , fontFreeSans, 12, conformanceLevel)); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
private String getZugfredExtension(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.ZUGFeRD: case PdfAConformanceLevel.ZUGFeRDBasic: return(String.Format(zugferdExtension, "BASIC")); case PdfAConformanceLevel.ZUGFeRDComfort: return(String.Format(zugferdExtension, "COMFORT")); case PdfAConformanceLevel.ZUGFeRDExtended: return(String.Format(zugferdExtension, "EXTENDED")); default: return(null); } }
public void CreatePdfA(PdfAConformanceLevel level) { Document doc = new Document(); MemoryStream stream = new MemoryStream(); PdfAWriter writer = PdfAWriter.GetInstance(doc, stream, level); doc.Open(); ICC_Profile icc = ICC_Profile.GetInstance(File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read)); writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc); writer.CreateXmpMetadata(); Font font = FontFactory.GetFont("FreeSans", BaseFont.IDENTITY_H, true, 12); doc.Add(new Phrase("Hello, " + level + " world!", font)); doc.Add(new Phrase(Guid.NewGuid().ToString(), font)); doc.Close(); }
public virtual void PdfA1DocWithPdfA1ComboBoxFieldTest() { String name = "pdfA1DocWithPdfA1ComboBoxField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf"; PdfFont fontCJK = PdfFontFactory.CreateFont(sourceFolder + "NotoSansCJKtc-Light.otf", PdfEncodings.IDENTITY_H , true); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); form.AddField(PdfFormField.CreateComboBox(pdfDoc, new Rectangle(156, 616, 70, 70), "combo", "用", new String [] { "用", "规", "表" }, fontCJK, conformanceLevel)); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
public virtual void PdfA1DocWithPdfA1ButtonFieldTest() { String name = "pdfA1DocWithPdfA1ButtonField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ButtonField.pdf"; Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); PdfFormField emptyField = PdfFormField.CreateEmptyField(pdfDoc, conformanceLevel).SetFieldName("empty"); emptyField.AddKid(PdfFormField.CreateButton(pdfDoc, new Rectangle(36, 756, 20, 20), PdfAnnotation.PRINT, conformanceLevel ).SetFieldName("button").SetValue("hello")); form.AddField(emptyField); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
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 async Task ShouldConvertToPdfA2B(string level, string part, string conformance) { var path = $"/pdfa"; var fixture = $"{Program.TestProjectPath}/Fixtures/dummy.pdf"; var pdfFile = await File.ReadAllBytesAsync(fixture); var formData = new PdfFormData().WithConformanceLevel(level).Upload(pdfFile); var response = await _client.PostAsync(path, formData); var stream = await response.Content.ReadAsStreamAsync(); var pdfa = new PdfADocument(new PdfReader(stream), new PdfWriter(new MemoryStream())); var xmpMetadataBytes = pdfa.GetXmpMetadata(); var xmpMetadata = XMPMetaFactory.ParseFromBuffer(xmpMetadataBytes); var conformanceLevel = PdfAConformanceLevel.GetConformanceLevel(xmpMetadata); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(part, conformanceLevel.GetPart()); Assert.Equal(conformance, conformanceLevel.GetConformance()); }
/** * * @param writer * @param conformanceLevel */ static public void SetPdfVersion(PdfWriter writer, PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: writer.PdfVersion = PdfWriter.VERSION_1_4; break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: writer.PdfVersion = PdfWriter.VERSION_1_7; break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: writer.PdfVersion = PdfWriter.VERSION_1_7; break; default: writer.PdfVersion = PdfWriter.VERSION_1_4; break; } }
public virtual void PdfA1DocWithPdfA1RadioButtonFieldTest() { String name = "pdfA1DocWithPdfA1RadioButtonField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1RadioButtonField.pdf"; Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); PdfButtonFormField radioGroup = PdfFormField.CreateRadioGroup(pdfDoc, "radio group", "", conformanceLevel); PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(36, 496, 20, 20), radioGroup, "1", conformanceLevel). SetBorderWidth(2).SetBorderColor(ColorConstants.ORANGE); PdfFormField.CreateRadioButton(pdfDoc, new Rectangle(66, 496, 20, 20), radioGroup, "2", conformanceLevel). SetBorderWidth(2).SetBorderColor(ColorConstants.ORANGE); form.AddField(radioGroup); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
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(); } }
/** * @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel) */ public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; switch(this.conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: case PdfAConformanceLevel.PDF_A_1B: pdfAChecker = new PdfA1Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_2A: case PdfAConformanceLevel.PDF_A_2B: case PdfAConformanceLevel.PDF_A_2U: pdfAChecker = new PdfA2Checker(conformanceLevel); break; case PdfAConformanceLevel.PDF_A_3A: case PdfAConformanceLevel.PDF_A_3B: case PdfAConformanceLevel.PDF_A_3U: pdfAChecker = new PdfA3Checker(conformanceLevel); break; default: pdfAChecker = new PdfA1Checker(conformanceLevel); break; } }
public virtual void PdfA1DocWithPdfA1ListFieldTest() { String name = "pdfA1DocWithPdfA1ListField"; String fileName = destinationFolder + name + ".pdf"; String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf"; PdfFont fontFreeSans = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, new PdfOutputIntent("Custom" , "", "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); PdfChoiceFormField f = PdfFormField.CreateList(pdfDoc, new Rectangle(86, 556, 50, 200), "list", "9", new String [] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, fontFreeSans, conformanceLevel); f.SetValue("4"); f.SetTopIndex(2); f.SetListSelected(new String[] { "3", "5" }); form.AddField(f); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(fileName, cmp, destinationFolder)); NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(fileName)); }
virtual public void XmpEncodingTest() { String fileName = "xmp_utf-8_encoding"; Document document = new Document(); PdfSmartCopy copy = new PdfSmartCopy(document, new FileStream(OUT_FOLDER + fileName, FileMode.Create)); document.Open(); PdfReader reader = new PdfReader(CMP_FOLDER + "pdf_metadata.pdf"); int pageCount = reader.NumberOfPages; for (int currentPage = 1; currentPage <= pageCount; currentPage++) { PdfImportedPage page = copy.GetImportedPage(reader, currentPage); copy.AddPage(page); } PdfAConformanceLevel pdfaLevel = PdfAConformanceLevel.PDF_A_1B; MemoryStream os = new MemoryStream(); PdfAXmpWriter xmp = new PdfAXmpWriter(os, copy.Info, pdfaLevel, copy); xmp.Close(); copy.XmpMetadata = os.ToArray(); string metadataXml = System.Text.Encoding.GetEncoding("UTF-8").GetString(copy.XmpMetadata); XmlDocument doc = new XmlDocument(); doc.LoadXml(metadataXml); //<-- This is where the exception is thrown document.Close(); copy.Close(); reader.Close(); }
/** * Constructs a <CODE>PdfAWriter</CODE>. * <P> * Remark: a PdfAWriter can only be constructed by calling the method <CODE>getInstance(Document document, Stream os, PdfAconformanceLevel conformanceLevel)</CODE>. * @param document the <CODE>PdfDocument</CODE> that has to be written * @param os the <CODE>Stream</CODE> the writer has to write to * @param conformanceLevel PDF/A conformance level of a new PDF document */ protected internal PdfAWriter(PdfDocument document, Stream os, PdfAConformanceLevel conformanceLevel) : base(document, os) { ((IPdfAConformance) pdfIsoConformance).SetConformanceLevel(conformanceLevel); SetPdfVersion(this, conformanceLevel); }
/** * @param conformanceLevel PDF/A conformance level of a new PDF document */ protected internal PdfAWriter(PdfAConformanceLevel conformanceLevel) : base() { ((IPdfAConformance) pdfIsoConformance).SetConformanceLevel(conformanceLevel); SetPdfVersion(this, conformanceLevel); }
/** * Starts the process of adding extra content to an existing PDF document keeping the document PDF/A conformant. * @param reader the original document. It cannot be reused * @param os the output stream * @param pdfVersion the new pdf version or '\0' to keep the same version as the original document * @param append if <CODE>true</CODE> appends the document changes as a new revision. This is only useful for multiple signatures as nothing is gained in speed or memory * @param conformanceLevel PDF/A conformance level of a new PDF document * @throws DocumentException on error * @throws IOException or error */ public PdfAStamper(PdfReader reader, Stream os, char pdfVersion, bool append, PdfAConformanceLevel conformanceLevel) { stamper = new PdfAStamperImp(reader, os, pdfVersion, append, conformanceLevel); }
/** * Creates and XMP writer that adds info about the PDF/A conformance level. * @param os * @param info * @param conformanceLevel * @throws IOException */ public PdfAXmpWriter(Stream os, IDictionary<string, string> info, PdfAConformanceLevel conformanceLevel) : base(os, info) { AddRdfDescription(conformanceLevel); }
protected internal ZugferdChecker(PdfAConformanceLevel conformanceLevel) : base(conformanceLevel) { }
/** * Adds information about the PDF/A conformance level to the XMP metadata. * * @param conformanceLevel * @throws IOException */ private void AddRdfDescription(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.PDF_A_1A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_1B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "1"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_2B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_2U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "2"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PdfAConformanceLevel.PDF_A_3A: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "A"); break; case PdfAConformanceLevel.PDF_A_3B: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); break; case PdfAConformanceLevel.PDF_A_3U: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "U"); break; case PdfAConformanceLevel.ZUGFeRD: case PdfAConformanceLevel.ZUGFeRDBasic: case PdfAConformanceLevel.ZUGFeRDComfort: case PdfAConformanceLevel.ZUGFeRDExtended: xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.PART, "3"); xmpMeta.SetProperty(XmpConst.NS_PDFA_ID, PdfAProperties.CONFORMANCE, "B"); IXmpMeta taggedExtensionMetaComfort = XmpMetaFactory.ParseFromString(getZugfredExtension(conformanceLevel)); XmpUtils.AppendProperties(taggedExtensionMetaComfort, xmpMeta, true, false); break; default: break; } if (writer.IsTagged()) { IXmpMeta taggedExtensionMeta = XmpMetaFactory.ParseFromString(pdfUaExtension); XmpUtils.AppendProperties(taggedExtensionMeta, xmpMeta, true, false); } }
internal PdfA1Checker(PdfAConformanceLevel conformanceLevel) :base(conformanceLevel) { }
// This method is used in the PdfA2CheckerTest and PdfA3CheckerTest, too public static void PdfObjectCheck(string output, PdfAConformanceLevel level, bool exceptionExpected) { FileStream fos = new FileStream(output, FileMode.Create); Document document = new Document(); PdfAWriter writer = PdfAWriter.GetInstance(document, fos, level); writer.CreateXmpMetadata(); document.Open(); Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12); document.Add(new Paragraph("Hello World", font)); FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read); ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream); iccProfileFileStream.Close(); writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc); PdfArray array = new PdfArray(); for (int i = 0; i < 8192; i++) { array.Add(new PdfNull()); } writer.ExtraCatalog.Put(new PdfName("TestArray"), array); bool exceptionThrown = false; try { document.Close(); } catch (PdfAConformanceException e) { if (e.GetObject().Equals(array)) exceptionThrown = true; } if (exceptionThrown != exceptionExpected) { String error = exceptionExpected ? "" : " not"; error = String.Format("PdfAConformanceException should{0} be thrown.", error); Assert.Fail(error); } }
/** * Applies a digital signature to a document, possibly as a new revision, making * possible multiple signatures. The returned PdfStamper * can be used normally as the signature is only applied when closing. * <p> * A possible use for adding a signature without invalidating an existing one is: * <p> * <pre> * KeyStore ks = KeyStore.getInstance("pkcs12"); * ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray()); * String alias = (String)ks.aliases().nextElement(); * PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray()); * Certificate[] chain = ks.getCertificateChain(alias); * PdfReader reader = new PdfReader("original.pdf"); * FileOutputStream fout = new FileOutputStream("signed.pdf"); * PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new * File("/temp"), true); * PdfSignatureAppearance sap = stp.getSignatureAppearance(); * sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED); * sap.setReason("I'm the author"); * sap.setLocation("Lisbon"); * // comment next line to have an invisible signature * sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); * stp.close(); * </pre> * @param reader the original document * @param os the output stream or <CODE>null</CODE> to keep the document in the temporary file * @param pdfVersion the new pdf version or '\0' to keep the same version as the original * document * @param tempFile location of the temporary file. If it's a directory a temporary file will be created there. * If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null. * In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE> * no temporary file will be created and memory will be used * @param append if <CODE>true</CODE> the signature and all the other content will be added as a * new revision thus not invalidating existing signatures * @param conformanceLevel PDF/A conformance level of a new PDF document * @return a <CODE>PdfAStamper</CODE> * @throws DocumentException on error * @throws IOException on error */ public static PdfAStamper CreateSignature(PdfReader reader, Stream os, char pdfVersion, String tempFile, bool append, PdfAConformanceLevel conformanceLevel) { PdfAStamper stp; if (tempFile == null) { ByteBuffer bout = new ByteBuffer(); stp = new PdfAStamper(reader, bout, pdfVersion, append, conformanceLevel); stp.sigApp = new PdfSignatureAppearance(stp.stamper); stp.sigApp.Sigout = bout; } else { if (Directory.Exists(tempFile)) { tempFile = Path.Combine(tempFile, Path.GetTempFileName()); tempFile += ".pdf"; } FileStream fout = new FileStream(tempFile, FileMode.Create); stp = new PdfAStamper(reader, fout, pdfVersion, append, conformanceLevel); stp.sigApp = new PdfSignatureAppearance(stp.stamper); stp.sigApp.SetTempFile(tempFile); } stp.sigApp.Originalout = os; stp.sigApp.SetStamper(stp); stp.hasSignature = true; PdfDictionary catalog = reader.Catalog; PdfDictionary acroForm = (PdfDictionary) PdfReader.GetPdfObject(catalog.Get(PdfName.ACROFORM), catalog); if (acroForm != null) { acroForm.Remove(PdfName.NEEDAPPEARANCES); stp.stamper.MarkUsed(acroForm); } return stp; }
/** * Applies a digital signature to a document. The returned PdfStamper * can be used normally as the signature is only applied when closing. * <p> * A possible use is: * <p> * <pre> * KeyStore ks = KeyStore.getInstance("pkcs12"); * ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray()); * String alias = (String)ks.aliases().nextElement(); * PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray()); * Certificate[] chain = ks.getCertificateChain(alias); * PdfReader reader = new PdfReader("original.pdf"); * FileOutputStream fout = new FileOutputStream("signed.pdf"); * PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new File("/temp")); * PdfSignatureAppearance sap = stp.getSignatureAppearance(); * sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED); * sap.setReason("I'm the author"); * sap.setLocation("Lisbon"); * // comment next line to have an invisible signature * sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); * stp.close(); * </pre> * @param reader the original document * @param os the output stream or <CODE>null</CODE> to keep the document in the temporary file * @param pdfVersion the new pdf version or '\0' to keep the same version as the original * document * @param tempFile location of the temporary file. If it's a directory a temporary file will be created there. * If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null. * In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE> * no temporary file will be created and memory will be used * @param conformanceLevel PDF/A conformance level of a new PDF document * @return a <CODE>PdfAStamper</CODE> * @throws DocumentException on error * @throws IOException on error */ public static PdfAStamper CreateSignature(PdfReader reader, Stream os, char pdfVersion, String tempFile, PdfAConformanceLevel conformanceLevel) { return CreateSignature(reader, os, pdfVersion, tempFile, false, conformanceLevel); }
/** * Constructor * * @param document document * @param os outputstream * @param conformanceLevel */ public PdfASmartCopy(Document document, Stream os, PdfAConformanceLevel conformanceLevel) : base(document, os, conformanceLevel) { this.streamMap = new Dictionary<PdfSmartCopy.ByteStore, PdfIndirectReference>(); }
internal PdfAChecker(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; }
/** * @see PdfAConformance#setConformanceLevel(com.itextpdf.text.pdf.PdfAConformanceLevel) */ public void SetConformanceLevel(PdfAConformanceLevel conformanceLevel) { this.conformanceLevel = conformanceLevel; }
/** * Creates and XMP writer that adds info about the PDF/A conformance level. * * @param os * @param info * @param conformanceLevel * @throws IOException */ public PdfAXmpWriter(Stream os, IDictionary<String, String> info, PdfAConformanceLevel conformanceLevel, PdfWriter writer) : base(os, info) { this.writer = writer; try { AddRdfDescription(conformanceLevel); } catch (XmpException xmpExc) { throw new IOException(xmpExc.Message); } }
public static bool CheckStructure(PdfAConformanceLevel conformanceLevel) { return conformanceLevel == PdfAConformanceLevel.PDF_A_1A || conformanceLevel == PdfAConformanceLevel.PDF_A_2A || conformanceLevel == PdfAConformanceLevel.PDF_A_3A; }
private String getZugfredExtension(PdfAConformanceLevel conformanceLevel) { switch (conformanceLevel) { case PdfAConformanceLevel.ZUGFeRD: case PdfAConformanceLevel.ZUGFeRDBasic: return String.Format(zugferdExtension, "BASIC"); case PdfAConformanceLevel.ZUGFeRDComfort: return String.Format(zugferdExtension, "COMFORT"); case PdfAConformanceLevel.ZUGFeRDExtended: return String.Format(zugferdExtension, "EXTENDED"); default: return null; } }
internal PdfAChecker(PdfAConformanceLevel conformanceLevel) { keysForCheck = InitKeysForCheck(); this.conformanceLevel = conformanceLevel; }
/** * @see TtfUnicodeWriter#TtfUnicodeWriter(PdfWriter) */ public PdfATtfUnicodeWriter(PdfWriter writer, PdfAConformanceLevel pdfAConformanceLevel) : base(writer) { this.pdfAConformanceLevel = pdfAConformanceLevel; }
/** * Constructor * * @param document document * @param os outputstream */ public PdfACopy(Document document, Stream os, PdfAConformanceLevel conformanceLevel) : base(document, os) { ((IPdfAConformance) pdfIsoConformance).SetConformanceLevel(conformanceLevel); PdfAWriter.SetPdfVersion(this, conformanceLevel); }
/** * Starts the process of adding extra content to an existing PDF document keeping the document PDF/A conformant. * @param reader the original document. It cannot be reused * @param os the output stream * @param conformanceLevel PDF/A conformance level of a new PDF document * @throws DocumentException on error * @throws IOException or error */ public PdfAStamper(PdfReader reader, Stream os, PdfAConformanceLevel conformanceLevel) { stamper = new PdfAStamperImp(reader, os, '\0', false, conformanceLevel); }