Example #1
0
        public virtual void DisabledVisualExpressionTest01()
        {
            String      srcPdf  = "sourceWithDifferentLayers.pdf";
            String      destPdf = "disabledVisualExpressionTest01.pdf";
            String      cmpPdf  = "cmp_" + destPdf;
            PdfDocument pdfDoc  = new PdfDocument(new PdfReader(sourceFolder + srcPdf), new PdfWriter(destinationFolder
                                                                                                      + destPdf));
            PdfCanvas canvas = new PdfCanvas(pdfDoc.GetFirstPage());

            canvas.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA), 18);
            IList <PdfLayer>   allLayers            = pdfDoc.GetCatalog().GetOCProperties(true).GetLayers();
            PdfLayerMembership layerMembershipAnyOn = new PdfLayerMembership(pdfDoc);
            // create expression with the AND operator as the first operand
            PdfVisibilityExpression expression = new PdfVisibilityExpression(PdfName.And);

            // add an empty dictionary as the second operand
            expression.AddOperand(allLayers[1]);
            // create a nested expression with the AND operator and two empty dictionaries as operands
            PdfVisibilityExpression nestedExpression = new PdfVisibilityExpression(PdfName.And);

            nestedExpression.AddOperand(allLayers[0]);
            nestedExpression.AddOperand(allLayers[2]);
            // add another expression as the third operand
            expression.AddOperand(nestedExpression);
            layerMembershipAnyOn.AddLayer(allLayers[0]);
            layerMembershipAnyOn.AddLayer(allLayers[1]);
            layerMembershipAnyOn.SetVisibilityExpression(expression);
            PdfLayerTestUtils.AddTextInsideLayer(layerMembershipAnyOn, canvas, "visualExpressionTest01", 200, 500);
            pdfDoc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + destPdf, sourceFolder
                                                                             + cmpPdf, destinationFolder));
        }
Example #2
0
        public virtual void DisabledVisibilityPolicyAllOnTest()
        {
            String      srcPdf  = "sourceWithDifferentLayers.pdf";
            String      destPdf = "disabledVisibilityPolicyAllOnTest.pdf";
            String      cmpPdf  = "cmp_" + destPdf;
            PdfDocument pdfDoc  = new PdfDocument(new PdfReader(sourceFolder + srcPdf), new PdfWriter(destinationFolder
                                                                                                      + destPdf));
            PdfCanvas canvas = new PdfCanvas(pdfDoc.GetFirstPage());

            canvas.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA), 18);
            IList <PdfLayer>   allLayers            = pdfDoc.GetCatalog().GetOCProperties(true).GetLayers();
            PdfLayerMembership layerMembershipAllOn = new PdfLayerMembership(pdfDoc);

            layerMembershipAllOn.AddLayer(allLayers[1]);
            layerMembershipAllOn.AddLayer(allLayers[0]);
            layerMembershipAllOn.SetVisibilityPolicy(PdfName.AllOn);
            PdfLayerTestUtils.AddTextInsideLayer(layerMembershipAllOn, canvas, "visibilityPolicyAllOnTest", 200, 500);
            pdfDoc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + destPdf, sourceFolder
                                                                             + cmpPdf, destinationFolder));
        }