Example #1
0
        //public static void GetTextFromPage(iTextSharp.text.pdf.PdfReader reader, int pageNumber, ITextExtractionStrategy strategy)
        //{
        //    PdfReaderContentParser parser = new PdfReaderContentParser(reader);
        //    //return parser.ProcessContent(pageNumber, strategy).GetResultantText();

        //    // PdfReaderContentParser.ProcessContent()
        //    PdfDictionary pageDic = reader.GetPageN(pageNumber);
        //    PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);

        //    PdfContentStreamProcessor processor = new PdfContentStreamProcessor(strategy);
        //    byte[] bytes = ContentByteUtils.GetContentBytesForPage(reader, pageNumber);
        //    processor.ProcessContent(bytes, resourcesDic);
        //    //return strategy.GetResultantText();
        //}

        public static string GetOperatorInfo(PdfLiteral ope)
        {
            string s = "";

            if (ope.IsArray())
            {
                s = "array";
            }
            if (ope.IsBoolean())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "bool";
            }
            if (ope.IsDictionary())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "dictionary";
            }
            if (ope.IsIndirect())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "indirect";
            }
            if (ope.IsName())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "name";
            }
            if (ope.IsNull())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "null";
            }
            if (ope.IsNumber())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "number";
            }
            if (ope.IsStream())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "stream";
            }
            if (ope.IsString())
            {
                if (s != "")
                {
                    s += "+";
                }
                s += "string";
            }
            if (s == "")
            {
                s = "???";
            }
            return(s);



            //RegisterContentOperator(DEFAULTOPERATOR, new IgnoreOperatorContentOperator());
            //RegisterContentOperator("q", new PushGraphicsState());
            //RegisterContentOperator("Q", new PopGraphicsState());
            //RegisterContentOperator("cm", new ModifyCurrentTransformationMatrix());
            //RegisterContentOperator("gs", new ProcessGraphicsStateResource());

            //SetTextCharacterSpacing tcOperator = new SetTextCharacterSpacing();
            //RegisterContentOperator("Tc", tcOperator);
            //SetTextWordSpacing twOperator = new SetTextWordSpacing();
            //RegisterContentOperator("Tw", twOperator);
            //RegisterContentOperator("Tz", new SetTextHorizontalScaling());
            //SetTextLeading tlOperator = new SetTextLeading();
            //RegisterContentOperator("TL", tlOperator);
            //RegisterContentOperator("Tf", new SetTextFont());
            //RegisterContentOperator("Tr", new SetTextRenderMode());
            //RegisterContentOperator("Ts", new SetTextRise());

            //RegisterContentOperator("BT", new BeginTextC());
            //RegisterContentOperator("ET", new EndTextC());
            //RegisterContentOperator("BMC", new BeginMarkedContentC());
            //RegisterContentOperator("BDC", new BeginMarkedContentDictionary());
            //RegisterContentOperator("EMC", new EndMarkedContentC());

            //TextMoveStartNextLine tdOperator = new TextMoveStartNextLine();
            //RegisterContentOperator("Td", tdOperator);
            //RegisterContentOperator("TD", new TextMoveStartNextLineWithLeading(tdOperator, tlOperator));
            //RegisterContentOperator("Tm", new TextSetTextMatrix());
            //TextMoveNextLine tstarOperator = new TextMoveNextLine(tdOperator);
            //RegisterContentOperator("T*", tstarOperator);

            //ShowText tjOperator = new ShowText();
            //RegisterContentOperator("Tj", new ShowText());
            //MoveNextLineAndShowText tickOperator = new MoveNextLineAndShowText(tstarOperator, tjOperator);
            //RegisterContentOperator("'", tickOperator);
            //RegisterContentOperator("\"", new MoveNextLineAndShowTextWithSpacing(twOperator, tcOperator, tickOperator));
            //RegisterContentOperator("TJ", new ShowTextArray());

            //RegisterContentOperator("Do", new Do());
        }