virtual public void CreatePdfTest() { String fileName = "xmp_metadata.pdf"; // step 1 Document document = new Document(); // step 2 PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(OUT_FOLDER + fileName, FileMode.Create)); MemoryStream os = new MemoryStream(); XmpWriter xmp = new XmpWriter(os, XmpWriter.UTF16, 2000); DublinCoreProperties.AddSubject(xmp.XmpMeta, "Hello World"); DublinCoreProperties.AddSubject(xmp.XmpMeta, "XMP & Metadata"); DublinCoreProperties.AddSubject(xmp.XmpMeta, "Metadata"); PdfProperties.SetKeywords(xmp.XmpMeta, "Hello World, XMP & Metadata, Metadata"); PdfProperties.SetVersion(xmp.XmpMeta, "1.4"); xmp.Close(); writer.XmpMetadata = os.ToArray(); // step 3 document.Open(); // step 4 document.Add(new Paragraph("Hello World")); // step 5 document.Close(); CompareResults(fileName, fileName); }
virtual public void CreatePdfTest() { String fileName = "xmp_metadata.pdf"; // step 1 Document document = new Document(); // step 2 PdfWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT_FOLDER + fileName, FileMode.Create), PdfAConformanceLevel.PDF_A_2B); writer.SetTagged(); writer.CreateXmpMetadata(); XmpWriter xmp = writer.XmpWriter; DublinCoreProperties.AddSubject(xmp.XmpMeta, "Hello World"); DublinCoreProperties.AddSubject(xmp.XmpMeta, "XMP & Metadata"); DublinCoreProperties.AddSubject(xmp.XmpMeta, "Metadata"); PdfProperties.SetKeywords(xmp.XmpMeta, "Hello World, XMP & Metadata, Metadata"); PdfProperties.SetVersion(xmp.XmpMeta, "1.4"); // step 3 document.Open(); document.AddLanguage("en_US"); // step 4 Font font = FontFactory.GetFont("../../resources/text/pdfa/FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12); document.Add(new Paragraph("Hello World", font)); FileStream iccStream = new FileStream("../../resources/text/pdfa/sRGB Color Space Profile.icm", FileMode.Open); ICC_Profile icc = ICC_Profile.GetInstance(iccStream); iccStream.Close(); writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc); // step 5 document.Close(); CompareResults(fileName, fileName); }