public virtual void CheckPatternWithoutTransparentFormResource() { using (MemoryStream bos = new MemoryStream()) { using (PdfWriter writer = new PdfWriter(bos)) { using (PdfDocument document = new PdfDocument(writer)) { PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(0f, 0f)); PdfPattern.Tiling tillingPattern = new PdfPattern.Tiling(0f, 0f); tillingPattern.GetResources().AddForm(formXObject); PdfPage pageToCheck = document.AddNewPage(); PdfResources pageResources = pageToCheck.GetResources(); pageResources.AddPattern(new PdfPattern.Shading(new PdfDictionary())); pageResources.AddPattern(tillingPattern); EnsureTransparencyObjectsNotEmpty(); // no assertions as we want to check that no exceptions would be thrown pdfA2Checker.CheckSinglePage(pageToCheck); } } } }
public virtual void CheckPatternWithTransparentFormResource() { using (MemoryStream bos = new MemoryStream()) { using (PdfWriter writer = new PdfWriter(bos)) { using (PdfDocument document = new PdfDocument(writer)) { PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(0f, 0f)); formXObject.SetGroup(new PdfTransparencyGroup()); PdfPattern.Tiling tillingPattern = new PdfPattern.Tiling(0f, 0f); tillingPattern.GetResources().AddForm(formXObject); PdfPage pageToCheck = document.AddNewPage(); PdfResources pageResources = pageToCheck.GetResources(); pageResources.AddPattern(new PdfPattern.Shading(new PdfDictionary())); pageResources.AddPattern(tillingPattern); NUnit.Framework.Assert.That(() => { pdfA2Checker.CheckSinglePage(pageToCheck); } , NUnit.Framework.Throws.InstanceOf <PdfAConformanceException>().With.Message.EqualTo(PdfAConformanceException.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE)) ; } } } }
/// <summary>Creates PdfPatternCanvas for a document from a provided Tiling pattern</summary> /// <param name="pattern">The Tiling pattern must be colored</param> /// <param name="document">The document that the resulting content stream will be written to</param> public PdfPatternCanvas(PdfPattern.Tiling pattern, PdfDocument document) : base((PdfStream)pattern.GetPdfObject(), pattern.GetResources(), document) { this.tilingPattern = pattern; }