Пример #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
                                          );
        }
        public virtual void Type3FontsWithIdentityFontMatrixAndMultiplier()
        {
            String      inputPdf    = sourceFolder + "type3FontsWithIdentityFontMatrixAndMultiplier.pdf";
            String      outputPdf   = destinationFolder + "type3FontsWithIdentityFontMatrixAndMultiplier.pdf";
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(inputPdf), new PdfWriter(outputPdf));

            GlyphBboxCalculationTest.CharacterPositionEventListener listener = new GlyphBboxCalculationTest.CharacterPositionEventListener
                                                                                   ();
            PdfCanvasProcessor processor = new PdfCanvasProcessor(listener);

            processor.ProcessPageContent(pdfDocument.GetPage(1));
            PdfPage   page      = pdfDocument.GetPage(1);
            Rectangle pageSize  = page.GetPageSize();
            PdfCanvas pdfCanvas = new PdfCanvas(page);

            pdfCanvas.BeginText().SetFontAndSize(processor.GetGraphicsState().GetFont(), processor.GetGraphicsState().
                                                 GetFontSize()).MoveText(pageSize.GetWidth() / 2 - 24, pageSize.GetHeight() / 2).ShowText("A").EndText(
                );
            pdfDocument.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outputPdf, sourceFolder + "cmp_type3FontsWithIdentityFontMatrixAndMultiplier.pdf"
                                                                             , destinationFolder, "diff_"));
        }