상속: System.Collections.ArrayList
예제 #1
0
        virtual public void DeprecatedLogicTest()
        {
            String fileName = "xmp_metadata_deprecated.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);
            MemoryStream os      = new MemoryStream();
            XmpWriter    xmp     = new PdfAXmpWriter(os, PdfAConformanceLevel.PDF_A_2B, writer);
            XmpSchema    dc      = new DublinCoreSchema();
            XmpArray     subject = new XmpArray(XmpArray.UNORDERED);

            subject.Add("Hello World");
            subject.Add("XMP & Metadata");
            subject.Add("Metadata");
            dc.SetProperty(DublinCoreSchema.SUBJECT, subject);
            xmp.AddRdfDescription(dc.Xmlns, dc.ToString());
            PdfSchema pdf = new PdfSchema();

            pdf.AddKeywords("Hello World, XMP & Metadata, Metadata");
            pdf.AddVersion("1.4");
            xmp.AddRdfDescription(pdf);
            xmp.Close();
            writer.XmpMetadata = os.ToArray();
            // 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("xmp_metadata_deprecated.pdf", fileName);
        }
예제 #2
0
// ---------------------------------------------------------------------------
/**
 * Creates a PDF document.
 */
    public byte[] CreatePdf() {
      using (MemoryStream ms = new MemoryStream()) {
        // step 1
        using (Document document = new Document()) {
        // step 2
          PdfWriter writer = PdfWriter.GetInstance(document, ms);
          using (MemoryStream msXmp = new MemoryStream()) {
            XmpWriter xmp = new XmpWriter(msXmp);
            XmpSchema dc = new DublinCoreSchema();
            XmpArray subject = new XmpArray(XmpArray.UNORDERED);
            subject.Add("Hello World");
            subject.Add("XMP & Metadata");
            subject.Add("Metadata");
            dc.SetProperty(DublinCoreSchema.SUBJECT, subject);
            xmp.AddRdfDescription(dc);
            PdfSchema pdf = new PdfSchema();
/*
 *  iTextSharp uses Item property instead of Java setProperty() method
 * 
 *      pdf.SetProperty(PdfSchema.KEYWORDS, "Hello World, XMP, Metadata");
 *      pdf.SetProperty(PdfSchema.VERSION, "1.4");
 */
            pdf[PdfSchema.KEYWORDS] = "Hello World, XMP, Metadata";
            pdf[PdfSchema.VERSION] = "1.4";
            xmp.AddRdfDescription(pdf);
            xmp.Close();
            writer.XmpMetadata = ms.ToArray();
          }
          // step 3
          document.Open();
          // step 4
          document.Add(new Paragraph("Hello World"));
        }
        return ms.ToArray();
      }
    }
예제 #3
0
 virtual public void DeprecatedLogicTest() {
     String fileName = "xmp_metadata_deprecated.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);
     XmpSchema dc = new DublinCoreSchema();
     XmpArray subject = new XmpArray(XmpArray.UNORDERED);
     subject.Add("Hello World");
     subject.Add("XMP & Metadata");
     subject.Add("Metadata");
     dc.SetProperty(DublinCoreSchema.SUBJECT, subject);
     xmp.AddRdfDescription(dc.Xmlns, dc.ToString());
     PdfSchema pdf = new PdfSchema();
     pdf.AddKeywords("Hello World, XMP & Metadata, Metadata");
     pdf.AddVersion("1.4");
     xmp.AddRdfDescription(pdf);
     xmp.Close();
     writer.XmpMetadata = os.ToArray();
     // step 3
     document.Open();
     // step 4
     document.Add(new Paragraph("Hello World"));
     // step 5
     document.Close();
     CompareResults("xmp_metadata.pdf", fileName);
 }
예제 #4
0
 virtual public void SetProperty(string key, XmpArray value)
 {
     base[key] = value.ToString();
 }
예제 #5
0
 public void SetProperty(string key, XmpArray value)
 {
     base[key] = value.ToString();
 }
예제 #6
0
 /** Adds the identifier.
 * @param id
 */
 virtual public void AddIdentifiers(String[] id) {
     XmpArray array = new XmpArray(XmpArray.UNORDERED);
     for (int i = 0; i < id.Length; i++) {
         array.Add(id[i]);
     }
     SetProperty(IDENTIFIER, array);
 }
예제 #7
0
 /**
 * Adds a title.
 * @param title
 */
 public void AddTitle(String title)
 {
     XmpArray array = new XmpArray(XmpArray.ALTERNATIVE);
     array.Add(title);
     SetProperty(TITLE, array);
 }
예제 #8
0
 /**
 * Adds a subject.
 * @param subject array of subjects
 */
 public void addSubject(String[] subject)
 {
     XmpArray array = new XmpArray(XmpArray.UNORDERED);
     for (int i = 0; i < subject.Length; i++) {
         array.Add(subject[i]);
     }
     SetProperty(SUBJECT, array);
 }
예제 #9
0
 /**
 * Adds a subject.
 * @param subject
 */
 public void AddSubject(String subject)
 {
     XmpArray array = new XmpArray(XmpArray.UNORDERED);
     array.Add(subject);
     SetProperty(SUBJECT, array);
 }
예제 #10
0
 /**
 * Adds an array of publishers.
 * @param publisher
 */
 public void AddPublisher(String[] publisher)
 {
     XmpArray array = new XmpArray(XmpArray.ORDERED);
     for (int i = 0; i < publisher.Length; i++) {
         array.Add(publisher[i]);
     }
     SetProperty(PUBLISHER, array);
 }
예제 #11
0
 /**
 * Adds a single publisher.
 * @param publisher
 */
 public void AddPublisher(String publisher)
 {
     XmpArray array = new XmpArray(XmpArray.ORDERED);
     array.Add(publisher);
     SetProperty(PUBLISHER, array);
 }
예제 #12
0
 /**
 * Adds a description.
 * @param desc
 */
 public void AddDescription(String desc)
 {
     XmpArray array = new XmpArray(XmpArray.ALTERNATIVE);
     array.Add(desc);
     SetProperty(DESCRIPTION, array);
 }
예제 #13
0
 /**
 * Adds an array of authors.
 * @param author
 */
 public void AddAuthor(String[] author)
 {
     XmpArray array = new XmpArray(XmpArray.ORDERED);
     for (int i = 0; i < author.Length; i++) {
         array.Add(author[i]);
     }
     SetProperty(CREATOR, array);
 }
예제 #14
0
 /**
 * Adds a single author.
 * @param author
 */
 public void AddAuthor(String author)
 {
     XmpArray array = new XmpArray(XmpArray.ORDERED);
     array.Add(author);
     SetProperty(CREATOR, array);
 }
예제 #15
0
        virtual public void DeprecatedLogicTest() {
            String fileName = "xmp_metadata_deprecated.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);
            MemoryStream os = new MemoryStream();
            XmpWriter xmp = new PdfAXmpWriter(os, PdfAConformanceLevel.PDF_A_2B, writer);
            XmpSchema dc = new DublinCoreSchema();
            XmpArray subject = new XmpArray(XmpArray.UNORDERED);
            subject.Add("Hello World");
            subject.Add("XMP & Metadata");
            subject.Add("Metadata");
            dc.SetProperty(DublinCoreSchema.SUBJECT, subject);
            xmp.AddRdfDescription(dc.Xmlns, dc.ToString());
            PdfSchema pdf = new PdfSchema();
            pdf.AddKeywords("Hello World, XMP & Metadata, Metadata");
            pdf.AddVersion("1.4");
            xmp.AddRdfDescription(pdf);
            xmp.Close();
            writer.XmpMetadata = os.ToArray();
            // 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("xmp_metadata_deprecated.pdf", fileName);
        }