public virtual void AnnotationCheckTest14()
        {
            String       outPdf = destinationFolder + "pdfA2a_annotationCheckTest14.pdf";
            String       cmpPdf = cmpFolder + "cmp_pdfA2a_annotationCheckTest14.pdf";
            PdfWriter    writer = new PdfWriter(outPdf);
            Stream       @is    = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfADocument doc    = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", ""
                                                                                                              , "http://www.color.org", "sRGB IEC61966-2.1", @is));

            doc.SetTagged();
            doc.GetCatalog().SetLang(new PdfString("en-US"));
            PdfPage       page      = doc.AddNewPage();
            Rectangle     annotRect = new Rectangle(100, 650, 400, 100);
            Rectangle     formRect  = new Rectangle(400, 100);
            PdfAnnotation annot     = new PdfStampAnnotation(annotRect);

            annot.SetFlags(PdfAnnotation.PRINT);
            annot.SetContents("Hello World");
            annot.SetNormalAppearance(CreateAppearance(doc, formRect));
            page.AddAnnotation(annot);
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
Beispiel #2
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument    pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
            ImageData      img    = ImageDataFactory.Create(IMG);
            float          width  = img.GetWidth();
            float          height = img.GetHeight();
            PdfFormXObject xObj   = new PdfFormXObject(new Rectangle(width, height));

            PdfCanvas canvas = new PdfCanvas(xObj, pdfDoc);

            canvas.AddImageAt(img, 0, 0, false);

            Rectangle          location = new Rectangle(36, 770 - height, width, height);
            PdfStampAnnotation stamp    = new PdfStampAnnotation(location);

            stamp.SetStampName(new PdfName("ITEXT"));
            stamp.SetNormalAppearance(xObj.GetPdfObject());

            // Set to print the annotation when the page is printed
            stamp.SetFlags(PdfAnnotation.PRINT);
            pdfDoc.GetFirstPage().AddAnnotation(stamp);

            pdfDoc.Close();
        }