public static void Run()
        {
            // ExStart:ExtractText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
            // Open input PDF
            PdfExtractor pdfExtractor = new PdfExtractor();

            pdfExtractor.BindPdf(dataDir + "ExtractText.pdf");

            // Use parameterless ExtractText method
            pdfExtractor.ExtractText();

            MemoryStream tempMemoryStream = new MemoryStream();

            pdfExtractor.GetText(tempMemoryStream);

            string text = "";

            // Specify Unicode encoding type in StreamReader constructor
            using (StreamReader streamReader = new StreamReader(tempMemoryStream, Encoding.Unicode))
            {
                streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                text = streamReader.ReadToEnd();
            }

            File.WriteAllText(dataDir + "output_out.txt", text);
            // ExEnd:ExtractText
        }
Esempio n. 2
0
        public static void Run()
        {
            // ExStart:AddText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();

            // Open document
            PdfFileMend mender = new PdfFileMend();

            // Create PdfFileMend object to add text
            mender.BindPdf(dataDir + "AddText.pdf");

            // Create formatted text
            FormattedText text = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.AliceBlue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, true, 14);

            // Set whether to use Word Wrap or not and using which mode
            mender.IsWordWrap = true;
            mender.WrapMode   = WordWrapMode.Default;

            // Add text in the PDF file
            mender.AddText(text, 1, 100, 200, 200, 400);

            // Save changes
            mender.Save(dataDir + "AddText_out.pdf");

            // Close PdfFileMend object
            mender.Close();
            // ExEnd:AddText
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
            //open input PDF
            PdfExtractor pdfExtractor = new PdfExtractor();

            pdfExtractor.BindPdf(dataDir + "ExtractText-Page.pdf");

            //use parameterless ExtractText method
            pdfExtractor.ExtractText();

            int pageNumber = 1;

            while (pdfExtractor.HasNextPageText())
            {
                MemoryStream tempMemoryStream = new MemoryStream();
                pdfExtractor.GetNextPageText(tempMemoryStream);
                string text = "";
                //specify Unicode encoding type in StreamReader constructor
                using (StreamReader streamReader = new
                                                   StreamReader(tempMemoryStream, Encoding.Unicode))
                {
                    streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                    text = streamReader.ReadToEnd();
                }
                File.WriteAllText(dataDir + "output" + pageNumber + ".txt", text);
                pageNumber++;
            }
        }
Esempio n. 4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
            //open input PDF
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            pdfContentEditor.BindPdf(dataDir + "ReplaceText-Page.pdf");
            //replace text on all pages
            pdfContentEditor.ReplaceText("Hello", 1, "World");
            //save output PDF
            pdfContentEditor.Save(dataDir + "ReplaceText.pdf");
        }