當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfContentStreamProcessor.ProcessContent方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.parser.PdfContentStreamProcessor.ProcessContent方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfContentStreamProcessor.ProcessContent方法的具體用法?C# PdfContentStreamProcessor.ProcessContent怎麽用?C# PdfContentStreamProcessor.ProcessContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.parser.PdfContentStreamProcessor的用法示例。


在下文中一共展示了PdfContentStreamProcessor.ProcessContent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: extractSnippets

 public void extractSnippets(String src, String dest)
 {
     TextWriter output = new StreamWriter(new FileStream(dest, FileMode.Create));
     PdfReader reader = new PdfReader(src);
     IRenderListener listener = new MyTextRenderListener(output);
     PdfContentStreamProcessor processor =
         new PdfContentStreamProcessor(listener);
     PdfDictionary pageDic = reader.GetPageN(1);
     PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
     processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, 1), resourcesDic);
     output.Flush();
     output.Close();
     reader.Close();
 }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:14,代碼來源:S05_ExtractSnippets.cs

示例2: WeirdHyphensTest

 virtual public void WeirdHyphensTest() {
     PdfReader reader = TestResourceUtils.GetResourceAsPdfReader(TEST_RESOURCES_PATH, "WeirdHyphens.pdf");
     List<String> textChunks = new List<String>();
     IRenderListener listener = new MyTextRenderListener(textChunks);
     PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener);
     PdfDictionary pageDic = reader.GetPageN(1);
     PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
     processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, 1), resourcesDic);
     /**
      * This assertion makes sure that encoding has been read properly from FontDescriptor.
      * If not the vallue will be "\u0000 14".
      */
     Assert.AreEqual("\u0096 14", textChunks[18]);
     reader.Close();
 }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:15,代碼來源:CMapAwareDocumentFontTest.cs

示例3: collectDataforDay

        /**
         * Put all data from given day into given table
         */
        public static void collectDataforDay(DateTime dateTime, SQLiteConnection m_dbConnection)
        {
            string zeroMonth = dateTime.Month < 10 ? "0" : "";
              string zeroDay = dateTime.Day < 10 ? "0" : "";
              string date = zeroMonth + dateTime.Month + "/" + zeroDay + dateTime.Day + "/" + dateTime.Year;

              PdfReader reader;
              try
              {
            reader = new PdfReader("http://www.equibase.com/premium/eqbPDFChartPlus.cfm?RACE=A&BorP=P&TID=SAR&CTRY=USA&DT=" + date + "&DAY=D&STYLE=EQB");
              }
              catch (Exception e)
              {
            Console.WriteLine("CAPTCHA TIME");
            Console.ReadKey();
            Console.ReadKey();

            reader = new PdfReader("http://www.equibase.com/premium/eqbPDFChartPlus.cfm?RACE=A&BorP=P&TID=SAR&CTRY=USA&DT=" + date + "&DAY=D&STYLE=EQB");
              }
              StringBuilder builder = new StringBuilder();

              for (int x = 1; x <= reader.NumberOfPages; x++)
              {
            PdfDictionary page = reader.GetPageN(x);
            IRenderListener listener = new SBTextRenderer(builder);
            PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener);
            PdfDictionary pageDic = reader.GetPageN(x);
            PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
            processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, x), resourcesDic);
              }

              if (pages.Count != 0)
              {

            DataHandler handler = new DataHandler(dateTime, pages, m_dbConnection);
            Thread thread = new Thread(new ThreadStart(handler.extractPdfData));

            thread.Start();
            thread.Join();
            reader.Dispose();
            pages.Clear();
              }
              else
              {
            // If there were no races on this particular day, simply skip it! :D
            Console.WriteLine("Invalid Date: " + date);
              }
        }
開發者ID:ryanlough,項目名稱:Horse-Racing-Analytic-Betting,代碼行數:51,代碼來源:Program.cs

示例4: ProcessBytes

        private void ProcessBytes(
            string resourceName,
            int pageNumber)
        {
            PdfReader pdfReader = TestResourceUtils.GetResourceAsPdfReader(TEST_RESOURCES_PATH, resourceName);

            PdfDictionary pageDictionary = pdfReader.GetPageN(pageNumber);

            PdfDictionary resourceDictionary = pageDictionary.GetAsDict(PdfName.RESOURCES);

            PdfObject contentObject = pageDictionary.Get(PdfName.CONTENTS);
            byte[] contentBytes = ReadContentBytes(contentObject);
            PdfContentStreamProcessor processor = new PdfContentStreamProcessor(_renderListener);
            processor.ProcessContent(contentBytes, resourceDictionary);

        }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:16,代碼來源:PdfContentStreamProcessorTest.cs

示例5: TestType3FontWidth

        public void TestType3FontWidth() {
            String inFile = "type3font_text.pdf";
            LineSegment origLineSegment = new LineSegment(new Vector(20.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f));

            PdfReader reader = TestResourceUtils.GetResourceAsPdfReader(TEST_RESOURCES_PATH, inFile);
            TextPositionRenderListener renderListener = new TextPositionRenderListener();
            PdfContentStreamProcessor processor = new PdfContentStreamProcessor(renderListener);

            PdfDictionary pageDic = reader.GetPageN(FIRST_PAGE);
            PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
            processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, FIRST_PAGE), resourcesDic);


            Assert.AreEqual(renderListener.LineSegments[FIRST_ELEMENT_INDEX].GetStartPoint()[FIRST_ELEMENT_INDEX],
                origLineSegment.GetStartPoint()[FIRST_ELEMENT_INDEX], 1/2f);

            Assert.AreEqual(renderListener.LineSegments[FIRST_ELEMENT_INDEX].GetEndPoint()[FIRST_ELEMENT_INDEX],
                origLineSegment.GetEndPoint()[FIRST_ELEMENT_INDEX], 1/2f);

        }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:20,代碼來源:TextRenderInfoTest.cs

示例6: SpaceTrimColumnTextTest

        public virtual void SpaceTrimColumnTextTest() {
            Document doc = new Document(PageSize.A4, 50, 30, 50, 30);
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(OUTSPTRIMCT, FileMode.Create));
            doc.Open();

            Phrase under = new Phrase();
            under.Font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.UNDERLINE);
            under.Add(new Chunk(" 1                                                      1                                                                                                                             9      "));

            Paragraph underlineTest = new Paragraph(under);
            underlineTest.KeepTogether = true;
            doc.Add(underlineTest);

            doc.Close();
            writer.Close();

            PdfReader reader = new PdfReader(OUTSPTRIMCT);
            MyTextRenderListener listener = new MyTextRenderListener();
            PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener);
            PdfDictionary pageDic = reader.GetPageN(1);
            PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
            processor.ProcessContent(ContentByteUtils.GetContentBytesForPage(reader, 1), resourcesDic);
            Assert.IsTrue(listener.GetText().Length == 60, "Unexpected text length");
        }
開發者ID:Niladri24dutta,項目名稱:itextsharp,代碼行數:24,代碼來源:ChunkTest.cs

示例7: HandleXObject

            public void HandleXObject(PdfContentStreamProcessor processor, PdfStream stream, PdfIndirectReference refi) {
                
                PdfDictionary resources = stream.GetAsDict(PdfName.RESOURCES);

                // we read the content bytes up here so if it fails we don't leave the graphics state stack corrupted
                // this is probably not necessary (if we fail on this, probably the entire content stream processing
                // operation should be rejected
                byte[] contentBytes;
                contentBytes = ContentByteUtils.GetContentBytesFromContentObject(stream);
                PdfArray matrix = stream.GetAsArray(PdfName.MATRIX);

                new PushGraphicsState().Invoke(processor, null, null);

                if (matrix != null){
                    float a = matrix.GetAsNumber(0).FloatValue;
                    float b = matrix.GetAsNumber(1).FloatValue;
                    float c = matrix.GetAsNumber(2).FloatValue;
                    float d = matrix.GetAsNumber(3).FloatValue;
                    float e = matrix.GetAsNumber(4).FloatValue;
                    float f = matrix.GetAsNumber(5).FloatValue;
                    Matrix formMatrix = new Matrix(a, b, c, d, e, f);

                    processor.Gs().ctm = formMatrix.Multiply(processor.Gs().ctm);
                }

                processor.ProcessContent(contentBytes, resources);

                new PopGraphicsState().Invoke(processor, null, null);
                
            }
開發者ID:Gianluigi,項目名稱:dssnet,代碼行數:30,代碼來源:PdfContentStreamProcessor.cs

示例8: CleanUpPage

        private void CleanUpPage(int pageNum, IList<PdfCleanUpLocation> cleanUpLocations) {
            if (cleanUpLocations.Count == 0) {
                return;
            }

            PdfReader pdfReader = pdfStamper.Reader;
            PdfDictionary page = pdfReader.GetPageN(pageNum);
            PdfContentByte canvas = pdfStamper.GetUnderContent(pageNum);
            byte[] pageContentInput = ContentByteUtils.GetContentBytesForPage(pdfReader, pageNum);
            page.Remove(PdfName.CONTENTS);

            canvas.SaveState();

            PdfCleanUpRegionFilter filter = CreateFilter(cleanUpLocations);
            PdfCleanUpRenderListener pdfCleanUpRenderListener = new PdfCleanUpRenderListener(pdfStamper, filter);
            pdfCleanUpRenderListener.RegisterNewContext(pdfReader.GetPageResources(page), canvas);

            PdfContentStreamProcessor contentProcessor = new PdfContentStreamProcessor(pdfCleanUpRenderListener);
            PdfCleanUpContentOperator.PopulateOperators(contentProcessor, pdfCleanUpRenderListener);
            contentProcessor.ProcessContent(pageContentInput, page.GetAsDict(PdfName.RESOURCES));
            pdfCleanUpRenderListener.PopContext();

            canvas.RestoreState();

            ColorCleanedLocations(canvas, cleanUpLocations);

            if (redactAnnotIndirRefs != null) { // if it isn't null, then we are in "extract locations from redact annots" mode
                DeleteRedactAnnots(pageNum);
            }
        }
開發者ID:yu0410aries,項目名稱:itextsharp,代碼行數:30,代碼來源:PdfCleanUpProcessor.cs


注:本文中的iTextSharp.text.pdf.parser.PdfContentStreamProcessor.ProcessContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。