Exemplo n.º 1
0
        public virtual void NotPrintNotOnPanel()
        {
            String      outPdf = destinationFolder + "notPrintNotOnPanel.pdf";
            String      cmpPdf = sourceFolder + "cmp_notPrintNotOnPanel.pdf";
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf));
            PdfFont     font   = PdfFontFactory.CreateFont();
            PdfLayer    notPrintedNotOnPanel = new PdfLayer("not printed", pdfDoc);

            notPrintedNotOnPanel.SetOnPanel(false);
            notPrintedNotOnPanel.SetPrint("Print", false);
            PdfCanvas canvas = new PdfCanvas(pdfDoc.AddNewPage());

            canvas.SetFontAndSize(font, 14);
            PdfLayerTestUtils.AddTextInsideLayer(null, canvas, "Normal page content, hello lorem ispum!", 100, 750);
            canvas.BeginLayer(notPrintedNotOnPanel);
            canvas.BeginText().SetFontAndSize(font, 24).MoveText(100, 700).ShowText("WHEN PRINTED THIS LINE IS NOT THERE"
                                                                                    ).EndText();
            canvas.BeginText().SetFontAndSize(font, 16).MoveText(100, 680).ShowText("(this text layer is not in the layers panel as well)"
                                                                                    ).EndText();
            canvas.EndLayer();
            pdfDoc.Close();
            PdfLayerTestUtils.CompareLayers(outPdf, cmpPdf);
        }