Exemple #1
0
        public virtual void PdfUncoloredPatternColorSize1Test()
        {
            PdfDocument   pdfDocument       = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));
            String        contentColorSpace = "/Cs1 cs\n";
            PdfDictionary pageDictionary    = (PdfDictionary) new PdfDictionary().MakeIndirect(pdfDocument);
            PdfStream     contentStream     = new PdfStream(contentColorSpace.GetBytes());

            pageDictionary.Put(PdfName.Contents, contentStream);
            PdfPage page = pdfDocument.AddNewPage();

            page.GetPdfObject().Put(PdfName.Contents, contentStream);
            PdfArray pdfArray = new PdfArray();

            pdfArray.Add(PdfName.Pattern);
            PdfColorSpace space = PdfColorSpace.MakeColorSpace(pdfArray);

            page.GetResources().AddColorSpace(space);
            Rectangle rectangle = new Rectangle(50, 50, 1000, 1000);

            page.SetMediaBox(rectangle);
            PdfCanvasProcessor processor = new PdfCanvasProcessor(new PdfArrayTest.NoOpListener());

            processor.ProcessPageContent(page);
            // Check if we reach the end of the test without failings together with verifying expected color space instance
            NUnit.Framework.Assert.IsTrue(processor.GetGraphicsState().GetFillColor().GetColorSpace() is PdfSpecialCs.Pattern
                                          );
        }