Inheritance: System.Collections.ArrayList
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
      }
    }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 virtual public void SetProperty(string key, XmpArray value)
 {
     base[key] = value.ToString();
 }
Ejemplo n.º 5
0
 public void SetProperty(string key, XmpArray value)
 {
     base[key] = value.ToString();
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 /**
 * Adds a title.
 * @param title
 */
 public void AddTitle(String title)
 {
     XmpArray array = new XmpArray(XmpArray.ALTERNATIVE);
     array.Add(title);
     SetProperty(TITLE, array);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 /**
 * Adds a subject.
 * @param subject
 */
 public void AddSubject(String subject)
 {
     XmpArray array = new XmpArray(XmpArray.UNORDERED);
     array.Add(subject);
     SetProperty(SUBJECT, array);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 12
0
 /**
 * Adds a description.
 * @param desc
 */
 public void AddDescription(String desc)
 {
     XmpArray array = new XmpArray(XmpArray.ALTERNATIVE);
     array.Add(desc);
     SetProperty(DESCRIPTION, array);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }