Example #1
0
 /**
  * Constructs a new Graphics State object with the default values.
  */
 public GraphicsState(){
     ctm = new Matrix();
     characterSpacing = 0;
     wordSpacing = 0;
     horizontalScaling = 1.0f;
     leading = 0;
     font = null;
     fontSize = 0;
     renderMode = 0;
     rise = 0;
     knockout = true;
 }
        virtual public void TestWidths() {
            PdfReader pdfReader = TestResourceUtils.GetResourceAsPdfReader(TEST_RESOURCES_PATH, "fontwithwidthissue.pdf");

            try {
                PdfDictionary fontsDic = pdfReader.GetPageN(1).GetAsDict(PdfName.RESOURCES).GetAsDict(PdfName.FONT);
                PRIndirectReference fontDicIndirect = (PRIndirectReference) fontsDic.Get(new PdfName("F1"));

                CMapAwareDocumentFont f = new CMapAwareDocumentFont(fontDicIndirect);
                Assert.IsTrue(f.GetWidth('h') != 0, "Width should not be 0");
            }
            finally {
                pdfReader.Close();
            }
        }
Example #3
0
 /**
  * Copy constructor.
  * @param source    another GraphicsState object
  */
 public GraphicsState(GraphicsState source){
     // note: all of the following are immutable, with the possible exception of font
     // so it is safe to copy them as-is
     ctm = source.ctm;
     characterSpacing = source.characterSpacing;
     wordSpacing = source.wordSpacing;
     horizontalScaling = source.horizontalScaling;
     leading = source.leading;
     font = source.font;
     fontSize = source.fontSize;
     renderMode = source.renderMode;
     rise = source.rise;
     knockout = source.knockout;
     colorSpaceFill = source.colorSpaceFill;
     colorSpaceStroke = source.colorSpaceStroke;
     fillColor = source.fillColor;
     strokeColor = source.strokeColor;
 }
Example #4
0
 /**
  * Constructs a new Graphics State object with the default values.
  */
 public GraphicsState(){
     ctm = new Matrix();
     characterSpacing = 0;
     wordSpacing = 0;
     horizontalScaling = 1.0f;
     leading = 0;
     font = null;
     fontSize = 0;
     renderMode = 0;
     rise = 0;
     knockout = true;
     colorSpaceFill = null;
     colorSpaceStroke = null;
     fillColor = null;
     strokeColor = null;
 }
Example #5
0
 /**
  * Gets the font pointed to by the indirect reference. The font may have been cached.
  * @param ind the indirect reference ponting to the font
  * @return the font
  * @since 5.0.6
  */
 private CMapAwareDocumentFont GetFont(PRIndirectReference ind) {
     CMapAwareDocumentFont font;
     cachedFonts.TryGetValue(ind.Number, out font);
     if (font == null) {
         font = new CMapAwareDocumentFont(ind);
         cachedFonts[ind.Number] = font;
     }
     return font;
 }
Example #6
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {

                PdfName dictionaryName = (PdfName)operands[0];
                PdfDictionary extGState = processor.resources.GetAsDict(PdfName.EXTGSTATE);
                if (extGState == null)
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("resources.do.not.contain.extgstate.entry.unable.to.process.oper.1", oper));
                PdfDictionary gsDic = extGState.GetAsDict(dictionaryName);
                if (gsDic == null)
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("1.is.an.unknown.graphics.state.dictionary", dictionaryName));

                // at this point, all we care about is the FONT entry in the GS dictionary
                PdfArray fontParameter = gsDic.GetAsArray(PdfName.FONT);
                if (fontParameter != null){
                    CMapAwareDocumentFont font = new CMapAwareDocumentFont((PRIndirectReference)fontParameter[0]);
                    float size = fontParameter.GetAsNumber(1).FloatValue;

                    processor.Gs().font = font;
                    processor.Gs().fontSize = size;
                }
            }
Example #7
0
            public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<PdfObject> operands) {
                PdfName fontResourceName = (PdfName)operands[0];
                float size = ((PdfNumber)operands[1]).FloatValue;

                PdfDictionary fontsDictionary = processor.resources.GetAsDict(PdfName.FONT);
                CMapAwareDocumentFont font = new CMapAwareDocumentFont((PRIndirectReference)fontsDictionary.Get(fontResourceName));

                processor.Gs().font = font;
                processor.Gs().fontSize = size;

            }