AddSubject() public static method

public static AddSubject ( IXmpMeta xmpMeta, String subject ) : void
xmpMeta IXmpMeta
subject String
return void
示例#1
0
        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);
        }
示例#2
0
        virtual public void ManipulatePdf2Test()
        {
            String     fileName = "xmp_metadata_added2.pdf";
            PdfReader  reader   = new PdfReader(CMP_FOLDER + "pdf_metadata.pdf");
            PdfStamper stamper  = new PdfStamper(reader, new FileStream(OUT_FOLDER + fileName, FileMode.Create));

            stamper.CreateXmpMetadata();
            XmpWriter xmp = stamper.XmpWriter;

            DublinCoreProperties.AddSubject(xmp.XmpMeta, "Hello World");
            DublinCoreProperties.AddSubject(xmp.XmpMeta, "XMP & Metadata");
            DublinCoreProperties.AddSubject(xmp.XmpMeta, "Metadata");

            PdfProperties.SetVersion(xmp.XmpMeta, "1.4");
            stamper.Close();
            reader.Close();

            CompareResults(fileName, fileName);
        }
示例#3
0
        virtual public void ManipulatePdf2Test()
        {
            String     fileName = "xmp_metadata_added2.pdf";
            PdfReader  reader   = new PdfReader(CMP_FOLDER + "pdf_metadata.pdf");
            PdfStamper stamper  = new PdfAStamper(reader, new FileStream(OUT_FOLDER + fileName, FileMode.Create),
                                                  PdfAConformanceLevel.PDF_A_1A);
            MemoryStream os  = new MemoryStream();
            XmpWriter    xmp = new PdfAXmpWriter(os, reader.Info, PdfAConformanceLevel.PDF_A_1A, stamper.Writer);

            DublinCoreProperties.AddSubject(xmp.XmpMeta, "Hello World");
            DublinCoreProperties.AddSubject(xmp.XmpMeta, "XMP & Metadata");
            DublinCoreProperties.AddSubject(xmp.XmpMeta, "Metadata");

            PdfProperties.SetVersion(xmp.XmpMeta, "1.4");
            xmp.Close();
            stamper.XmpMetadata = os.ToArray();
            stamper.Close();
            reader.Close();
            CompareResults(fileName, fileName);
        }
示例#4
0
        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);
        }
示例#5
0
        virtual public void XmpEncodingTest()
        {
            String       fileName = "xmp_UTF-16BE-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);
            }


            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");
            xmp.Close();

            copy.XmpMetadata = os.ToArray();

            string metadataXml = System.Text.Encoding.GetEncoding("UTF-16BE").GetString(copy.XmpMetadata);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(metadataXml);  //<-- This is where the exception is thrown


            document.Close();
            copy.Close();
            reader.Close();
        }