public virtual void ImageCheckTest1()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.AddImage(ImageDataFactory.Create(sourceFolder + "jpeg2000/p0_01.j2k"), 300, 300, false);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ONLY_JPX_BASELINE_SET_OF_FEATURES_SHALL_BE_USED))
     ;
 }
 public virtual void ImageCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.AddImage(ImageDataFactory.Create(sourceFolder + "jpeg2000/file7.jp2"), 300, 300, false);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.ExactlyOneColourSpaceSpecificationShallHaveTheValue0x01InTheApproxField));
     ;
 }
Exemple #3
0
 public virtual void AcroFormCheck04()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         doc.AddNewPage();
         PdfDictionary acroForm = new PdfDictionary();
         acroForm.Put(PdfName.XFA, new PdfArray());
         doc.GetCatalog().Put(PdfName.AcroForm, acroForm);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY))
     ;
 }
Exemple #4
0
 public virtual void AcroFormCheck04()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         doc.AddNewPage();
         PdfDictionary acroForm = new PdfDictionary();
         acroForm.Put(PdfName.XFA, new PdfArray());
         doc.GetCatalog().Put(PdfName.AcroForm, acroForm);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.TheInteractiveFormDictionaryShallNotContainTheXfaKey));
     ;
 }
 public virtual void ActionCheck03()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         doc.AddNewPage();
         PdfDictionary openActions = new PdfDictionary();
         openActions.Put(PdfName.S, PdfName.Sound);
         doc.GetCatalog().Put(PdfName.OpenAction, openActions);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(MessageFormatUtil.Format(PdfAConformanceException._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Sound.GetValue())));
     ;
 }
Exemple #6
0
 public virtual void ImageCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.AddImage(ImageDataFactory.Create(sourceFolder + "jpeg2000/file7.jp2"), 300, 300, false);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD))
     ;
 }
Exemple #7
0
 public virtual void AcroFormCheck01()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         doc.AddNewPage();
         PdfDictionary acroForm = new PdfDictionary();
         acroForm.Put(PdfName.NeedAppearances, new PdfBoolean(true));
         doc.GetCatalog().Put(PdfName.AcroForm, acroForm);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE))
     ;
 }
 public virtual void ActionCheck10()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page         = doc.AddNewPage();
         PdfDictionary action = new PdfDictionary();
         action.Put(PdfName.S, PdfName.SetState);
         page.SetAdditionalAction(PdfName.C, new PdfAction(action));
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED));
     ;
 }
Exemple #9
0
 public virtual void CanvasCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent);
         pdfDocument.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(pdfDocument.GetLastPage());
         canvas.SetRenderingIntent(new PdfName("Test"));
         pdfDocument.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.IfSpecifiedRenderingShallBeOneOfTheFollowingRelativecolorimetricAbsolutecolorimetricPerceptualOrSaturation));
     ;
 }
 public virtual void AnnotationCheckTest01()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page        = doc.AddNewPage();
         Rectangle rect      = new Rectangle(100, 100, 100, 100);
         PdfAnnotation annot = new PdfFileAttachmentAnnotation(rect);
         page.AddAnnotation(annot);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(MessageFormatUtil.Format(PdfAConformanceException.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.FileAttachment.GetValue())))
     ;
 }
Exemple #11
0
        public virtual void AcroFormCheck03()
        {
            String       outPdf = destinationFolder + "pdfA1b_acroFormCheck03.pdf";
            String       cmpPdf = cmpFolder + "cmp_pdfA1b_acroFormCheck03.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_1B, new PdfOutputIntent("Custom", ""
                                                                                                              , "http://www.color.org", "sRGB IEC61966-2.1", @is));

            doc.AddNewPage();
            PdfDictionary acroForm = new PdfDictionary();

            doc.GetCatalog().Put(PdfName.AcroForm, acroForm);
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
        public virtual void AnnotationCheckTest02()
        {
            String       outPdf = destinationFolder + "pdfA2b_annotationCheckTest02.pdf";
            String       cmpPdf = cmpFolder + "cmp_pdfA2b_annotationCheckTest02.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_2B, new PdfOutputIntent("Custom", ""
                                                                                                              , "http://www.color.org", "sRGB IEC61966-2.1", @is));
            PdfPage       page  = doc.AddNewPage();
            Rectangle     rect  = new Rectangle(100, 650, 400, 100);
            PdfAnnotation annot = new PdfPopupAnnotation(rect);

            page.AddAnnotation(annot);
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
 public virtual void AnnotationCheckTest01()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page        = doc.AddNewPage();
         Rectangle rect      = new Rectangle(100, 650, 400, 100);
         PdfAnnotation annot = new PdfFileAttachmentAnnotation(rect);
         page.AddAnnotation(annot);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY));
     ;
 }
 public virtual void CatalogCheck09()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         doc.AddNewPage();
         PdfDictionary names = new PdfDictionary();
         names.Put(PdfName.AlternatePresentations, new PdfDictionary());
         doc.GetCatalog().Put(PdfName.Names, names);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATEPRESENTATIONS_NAMES_ENTRY));
     ;
 }
 public virtual void CanvasCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent);
         pdfDocument.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(pdfDocument.GetLastPage());
         canvas.SetRenderingIntent(new PdfName("Test"));
         pdfDocument.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.IF_SPECIFIED_RENDERING_SHALL_BE_ONE_OF_THE_FOLLOWING_RELATIVECOLORIMETRIC_ABSOLUTECOLORIMETRIC_PERCEPTUAL_OR_SATURATION))
     ;
 }
 public virtual void ImageTransparencyTest()
 {
     NUnit.Framework.Assert.That(() => {
         PdfDocument pdfDoc = new PdfADocument(new PdfWriter(new MemoryStream()), PdfAConformanceLevel.PDF_A_3B, null
                                               );
         PdfPage page     = pdfDoc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(page);
         page.GetResources().SetDefaultRgb(new PdfCieBasedCs.CalRgb(new float[] { 0.3f, 0.4f, 0.5f }));
         canvas.SaveState();
         canvas.AddImage(ImageDataFactory.Create(sourceFolder + "itext.png"), 0, 0, page.GetPageSize().GetWidth() /
                         2, false);
         canvas.RestoreState();
         pdfDoc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(MessageFormatUtil.Format(PdfAConformanceException.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE)))
     ;
 }
Exemple #17
0
 public virtual void ColorCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new MemoryStream());
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, null);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.SetFillColor(Color.GREEN);
         canvas.MoveTo(doc.GetDefaultPageSize().GetLeft(), doc.GetDefaultPageSize().GetBottom());
         canvas.LineTo(doc.GetDefaultPageSize().GetRight(), doc.GetDefaultPageSize().GetBottom());
         canvas.LineTo(doc.GetDefaultPageSize().GetRight(), doc.GetDefaultPageSize().GetTop());
         canvas.Fill();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.IfDeviceRgbCmykGrayUsedInFileThatFileShallContainPdfaOutputIntent));
     ;
 }
 public virtual void AnnotationCheckTest06()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page        = doc.AddNewPage();
         Rectangle rect      = new Rectangle(100, 650, 400, 100);
         PdfAnnotation annot = new PdfTextAnnotation(rect);
         annot.SetFlags(PdfAnnotation.PRINT | PdfAnnotation.INVISIBLE);
         page.AddAnnotation(annot);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0))
     ;
 }
Exemple #19
0
 public virtual void EgsCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.SetExtGState(new PdfExtGState().SetTransferFunction2(new PdfName("Test")));
         canvas.Rectangle(30, 30, 100, 100).Fill();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.AnExtgstateDictionaryShallNotContainTheTR2KeyWithAValueOtherThanDefault));
     ;
 }
 public virtual void FontCheckPdfA1_04()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new MemoryStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfDocument doc  = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page     = doc.AddNewPage();
         PdfFont font     = PdfFontFactory.CreateFont("Helvetica", "WinAnsi", true);
         PdfCanvas canvas = new PdfCanvas(page);
         canvas.SaveState().SetFillColor(DeviceRgb.GREEN).BeginText().MoveText(36, 700).SetFontAndSize(font, 36).ShowText
             ("Hello World! Pdf/A-1B").EndText().RestoreState();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.AllFontsMustBeEmbeddedThisOneIsnt1));
     ;
 }
Exemple #21
0
 public virtual void EgsCheckTest1()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.SetExtGState(new PdfExtGState().Put(PdfName.HTP, new PdfName("Test")));
         canvas.Rectangle(30, 30, 100, 100).Fill();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_HTP_KEY))
     ;
 }
Exemple #22
0
 public virtual void ColorCheckTest3()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new MemoryStream());
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, null);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.SetFillColor(ColorConstants.GREEN);
         canvas.MoveTo(doc.GetDefaultPageSize().GetLeft(), doc.GetDefaultPageSize().GetBottom());
         canvas.LineTo(doc.GetDefaultPageSize().GetRight(), doc.GetDefaultPageSize().GetBottom());
         canvas.LineTo(doc.GetDefaultPageSize().GetRight(), doc.GetDefaultPageSize().GetTop());
         canvas.Fill();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT));
     ;
 }
Exemple #23
0
 public virtual void AnnotationCheckTest03()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page              = doc.AddNewPage();
         Rectangle rect            = new Rectangle(100, 100, 100, 100);
         PdfMarkupAnnotation annot = new PdfTextAnnotation(rect);
         annot.SetFlag(0);
         page.AddAnnotation(annot);
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.TheFKeysPrintFlagBitShallBeSetTo1AndItsHiddenInvisibleAndNoviewFlagBitsShallBeSetTo0));
     ;
 }
Exemple #24
0
 public virtual void TransparencyCheckTest2()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer             = new PdfWriter(new MemoryStream());
         Stream @is                   = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                            , @is);
         PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent);
         doc.AddNewPage();
         PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());
         canvas.SetExtGState(new PdfExtGState().SetSoftMask(new PdfName("Test")));
         canvas.Rectangle(30, 30, 100, 100).Fill();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.TypeOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_EXTGSTATE));
     ;
 }
 public virtual void FontCheckPdfA1_02()
 {
     NUnit.Framework.Assert.That(() => {
         PdfWriter writer = new PdfWriter(new MemoryStream());
         Stream @is       = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
         PdfDocument doc  = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                        , "http://www.color.org", "sRGB IEC61966-2.1", @is));
         PdfPage page     = doc.AddNewPage();
         PdfFont font     = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi");
         PdfCanvas canvas = new PdfCanvas(page);
         canvas.SaveState().SetFillColor(ColorConstants.GREEN).BeginText().MoveText(36, 700).SetFontAndSize(font, 36
                                                                                                            ).ShowText("Hello World! Pdf/A-1B").EndText().RestoreState();
         doc.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(MessageFormatUtil.Format(PdfAConformanceException.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "FreeSans")))
     ;
 }
        public virtual void FontCheckPdfA1_01()
        {
            String      outPdf = outputDir + "pdfA1b_fontCheckPdfA1_01.pdf";
            String      cmpPdf = sourceFolder + "cmp/PdfAFontTest/cmp_pdfA1b_fontCheckPdfA1_01.pdf";
            PdfWriter   writer = new PdfWriter(outPdf);
            Stream      @is    = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfDocument doc    = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", ""
                                                                                                             , "http://www.color.org", "sRGB IEC61966-2.1", @is));
            PdfPage   page   = doc.AddNewPage();
            PdfFont   font   = PdfFontFactory.CreateFont(sourceFolder + "FreeSans.ttf", "WinAnsi", true);
            PdfCanvas canvas = new PdfCanvas(page);

            canvas.SaveState().SetFillColor(ColorConstants.GREEN).BeginText().MoveText(36, 700).SetFontAndSize(font, 36
                                                                                                               ).ShowText("Hello World! Pdf/A-1B").EndText().RestoreState();
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
Exemple #27
0
        public virtual void TransparencyCheckTest3()
        {
            String          outPdf       = destinationFolder + "pdfA1b_transparencyCheckTest3.pdf";
            String          cmpPdf       = cmpFolder + "cmp_pdfA1b_transparencyCheckTest3.pdf";
            PdfWriter       writer       = new PdfWriter(outPdf);
            Stream          @is          = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                               , @is);
            PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent);

            doc.AddNewPage();
            PdfCanvas canvas = new PdfCanvas(doc.GetLastPage());

            canvas.SetExtGState(new PdfExtGState().SetSoftMask(PdfName.None));
            canvas.Rectangle(30, 30, 100, 100).Fill();
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
        public virtual void KeywordsInfoTestPdfA2b()
        {
            String          outFile      = destinationFolder + "keywordsInfoTestPdfA2b.pdf";
            String          cmpFile      = cmpFolder + "cmp_keywordsInfoTestPdfA2b.pdf";
            Stream          @is          = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1"
                                                               , @is);
            PdfADocument doc = new PdfADocument(new PdfWriter(outFile), PdfAConformanceLevel.PDF_A_2B, outputIntent);

            doc.AddNewPage();
            doc.GetDocumentInfo().SetKeywords("key1, key2 , key3;key4,key5");
            doc.Close();
            CompareTool ct = new CompareTool();

            NUnit.Framework.Assert.IsNull(ct.CompareByContent(outFile, cmpFile, destinationFolder));
            NUnit.Framework.Assert.IsNull(ct.CompareDocumentInfo(outFile, cmpFile));
            NUnit.Framework.Assert.IsNull(ct.CompareXmp(outFile, cmpFile, true));
        }
        private void CreateDocumentWithFont(String outFileName, String fontFileName, String encoding, PdfAConformanceLevel
                                            conformanceLevel)
        {
            String      outPdf = outputDir + outFileName;
            String      cmpPdf = sourceFolder + "cmp/PdfAFontTest/cmp_" + outFileName;
            PdfWriter   writer = new PdfWriter(outPdf);
            Stream      @is    = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfDocument doc    = new PdfADocument(writer, conformanceLevel, new PdfOutputIntent("Custom", "", "http://www.color.org"
                                                                                                , "sRGB IEC61966-2.1", @is));
            PdfPage   page   = doc.AddNewPage();
            PdfFont   font   = PdfFontFactory.CreateFont(sourceFolder + fontFileName, encoding, true);
            PdfCanvas canvas = new PdfCanvas(page);

            canvas.SaveState().BeginText().MoveText(36, 700).SetFontAndSize(font, 12).ShowText("Hello World").EndText(
                ).RestoreState();
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }
        public virtual void CidFontCheckTest3()
        {
            String      outPdf = outputDir + "pdfA2b_cidFontCheckTest3.pdf";
            String      cmpPdf = sourceFolder + "cmp/PdfAFontTest/cmp_pdfA2b_cidFontCheckTest3.pdf";
            PdfWriter   writer = new PdfWriter(outPdf);
            Stream      @is    = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read);
            PdfDocument doc    = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", ""
                                                                                                             , "http://www.color.org", "sRGB IEC61966-2.1", @is));
            PdfPage page = doc.AddNewPage();
            // Identity-H must be embedded
            PdfFont   font   = PdfFontFactory.CreateFont(sourceFolder + "NotoSansCJKtc-Light.otf", "Identity-H", true);
            PdfCanvas canvas = new PdfCanvas(page);

            canvas.SaveState().BeginText().MoveText(36, 700).SetFontAndSize(font, 12).ShowText("Hello World").EndText(
                ).RestoreState();
            doc.Close();
            CompareResult(outPdf, cmpPdf);
        }