ApiExamples.DocumentHelper.CreateDocumentFillWithDummyText C# (CSharp) Метод

CreateDocumentFillWithDummyText() статический приватный Метод

Create new document with text
static private CreateDocumentFillWithDummyText ( ) : Document
Результат Document
        internal static Document CreateDocumentFillWithDummyText()
        {
            Document doc = new Document();

            //Remove the previous changes of the document
            doc.RemoveAllChildren();

            //Set the document author
            doc.BuiltInDocumentProperties.Author = "Test Author";

            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.Write("Page ");
            builder.InsertField("PAGE", "");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES", "");

            //Insert new table with two rows and two cells
            InsertTable(builder);

            builder.Writeln("Hello World!");

            // Continued on page 2 of the document content
            builder.InsertBreak(BreakType.PageBreak);

            //Insert TOC entries
            InsertToc(builder);

            return doc;
        }

Usage Example

        public void WithoutUpdateFields()
        {
            //ExStart
            //ExFor:PdfSaveOptions.Clone
            //ExFor:SaveOptions.UpdateFields
            //ExSummary:Shows how to update fields before saving into a PDF document.
            Document doc = DocumentHelper.CreateDocumentFillWithDummyText();

            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions
            {
                UpdateFields = false
            };

            // PdfSaveOptions objects can be cloned
            Assert.AreNotSame(pdfSaveOptions, pdfSaveOptions.Clone());

            doc.Save(ArtifactsDir + "UpdateFields_False.pdf", pdfSaveOptions);
            //ExEnd
#if !(__MOBILE__ || MAC)
            Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "UpdateFields_False.pdf");

            // Get text fragment by search String
            Aspose.Pdf.Text.TextFragmentAbsorber textFragmentAbsorber = new Aspose.Pdf.Text.TextFragmentAbsorber("Page  of");
            pdfDocument.Pages.Accept(textFragmentAbsorber);

            // Assert that fields are not updated
            Assert.AreEqual("Page  of", textFragmentAbsorber.TextFragments[1].Text);
#endif
        }
All Usage Examples Of ApiExamples.DocumentHelper::CreateDocumentFillWithDummyText