Beispiel #1
0
        public virtual void TestInheritedResources()
        {
            PdfDocument   pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "simpleInheritedResources.pdf"));
            PdfPage       page        = pdfDocument.GetPage(1);
            PdfDictionary dict        = page.GetResources().GetResource(PdfName.ExtGState);

            NUnit.Framework.Assert.AreEqual(2, dict.Size());
            PdfExtGState gState = new PdfExtGState((PdfDictionary)dict.Get(new PdfName("Gs1")));

            NUnit.Framework.Assert.AreEqual(10, gState.GetLineWidth());
        }
Beispiel #2
0
        /// <summary>Updates current graphic state with values from extended graphic state dictionary.</summary>
        /// <param name="extGState">the wrapper around the extended graphic state dictionary</param>
        /// <param name="pdfDocument">the document to retrieve fonts from. Needed when the newly created fonts are used
        ///     </param>
        internal virtual void UpdateFromExtGState(PdfExtGState extGState, PdfDocument pdfDocument)
        {
            float?lw = extGState.GetLineWidth();

            if (lw != null)
            {
                lineWidth = (float)lw;
            }
            int?lc = extGState.GetLineCapStyle();

            if (lc != null)
            {
                lineCapStyle = (int)lc;
            }
            int?lj = extGState.GetLineJoinStyle();

            if (lj != null)
            {
                lineJoinStyle = (int)lj;
            }
            float?ml = extGState.GetMiterLimit();

            if (ml != null)
            {
                miterLimit = (float)ml;
            }
            PdfArray d = extGState.GetDashPattern();

            if (d != null)
            {
                dashPattern = d;
            }
            PdfName ri = extGState.GetRenderingIntent();

            if (ri != null)
            {
                renderingIntent = ri;
            }
            bool?op = extGState.GetStrokeOverprintFlag();

            if (op != null)
            {
                strokeOverprint = (bool)op;
            }
            op = extGState.GetFillOverprintFlag();
            if (op != null)
            {
                fillOverprint = (bool)op;
            }
            int?opm = extGState.GetOverprintMode();

            if (opm != null)
            {
                overprintMode = (int)opm;
            }
            PdfArray fnt = extGState.GetFont();

            if (fnt != null)
            {
                PdfDictionary fontDictionary = fnt.GetAsDictionary(0);
                if (this.font == null || this.font.GetPdfObject() != fontDictionary)
                {
                    this.font = pdfDocument.GetFont(fontDictionary);
                }
                PdfNumber fntSz = fnt.GetAsNumber(1);
                if (fntSz != null)
                {
                    this.fontSize = fntSz.FloatValue();
                }
            }
            PdfObject bg = extGState.GetBlackGenerationFunction();

            if (bg != null)
            {
                blackGenerationFunction = bg;
            }
            PdfObject bg2 = extGState.GetBlackGenerationFunction2();

            if (bg2 != null)
            {
                blackGenerationFunction2 = bg2;
            }
            PdfObject ucr = extGState.GetUndercolorRemovalFunction();

            if (ucr != null)
            {
                underColorRemovalFunction = ucr;
            }
            PdfObject ucr2 = extGState.GetUndercolorRemovalFunction2();

            if (ucr2 != null)
            {
                underColorRemovalFunction2 = ucr2;
            }
            PdfObject tr = extGState.GetTransferFunction();

            if (tr != null)
            {
                transferFunction = tr;
            }
            PdfObject tr2 = extGState.GetTransferFunction2();

            if (tr2 != null)
            {
                transferFunction2 = tr2;
            }
            PdfObject ht = extGState.GetHalftone();

            if (ht != null)
            {
                halftone = ht;
            }
            PdfObject local_htp = extGState.GetPdfObject().Get(PdfName.HTP);

            if (local_htp != null)
            {
                this.htp = local_htp;
            }
            float?fl = extGState.GetFlatnessTolerance();

            if (fl != null)
            {
                flatnessTolerance = (float)fl;
            }
            float?sm = extGState.GetSmothnessTolerance();

            if (sm != null)
            {
                smoothnessTolerance = sm;
            }
            bool?sa = extGState.GetAutomaticStrokeAdjustmentFlag();

            if (sa != null)
            {
                automaticStrokeAdjustment = (bool)sa;
            }
            PdfObject bm = extGState.GetBlendMode();

            if (bm != null)
            {
                blendMode = bm;
            }
            PdfObject sMask = extGState.GetSoftMask();

            if (sMask != null)
            {
                softMask = sMask;
            }
            float?ca = extGState.GetStrokeOpacity();

            if (ca != null)
            {
                strokeAlpha = (float)ca;
            }
            ca = extGState.GetFillOpacity();
            if (ca != null)
            {
                fillAlpha = (float)ca;
            }
            bool?ais = extGState.GetAlphaSourceFlag();

            if (ais != null)
            {
                alphaIsShape = (bool)ais;
            }
            bool?tk = extGState.GetTextKnockoutFlag();

            if (tk != null)
            {
                textKnockout = (bool)tk;
            }
        }