Next, new separate TextFormat objects are created to format the captions and paragraphs, and a new TextLayout object is created to specify the page margins.įinally, a new TextSplitOptions object is made to handle pagination.Using the new ITextMap.Paragraphs property, the code required to perform this task is straightforward: // Open an arbitrary PDF, load it into a temp document and get all page texts: Then it adds a sample explanation note on the first page using the helper function AddNote. ] Code Analysis of GcPdf Parsing/Reading PDF with CĪ new GcPdfDocument doc object is created and generates a new page using the NewPagemethod. TextSplitOptions to = new TextSplitOptions(tl) Text split options for widow/orphan control: New RectangleF(margin, margin, - margin * 2, 0)) įont = (Path.Combine("Resources", "Fonts", "yumin.ttf")), "The original PDF is appended to the generated document for reference.", "We alternate the background color for the paragraphs so that the bounds between paragraphs are more clear. "and iterate over the pages of that document, printing all paragraphs found on the page. "Here we load an existing PDF (Wetlands) into a temporary GcPdfDocument, " The code extracts the text paragraphs on each page, rendering each section in alternating colors (for clarity) in a new PDF document:įigure 2 Extract Paragraphs from a PDF Sampleįirst, the code creates a new PDF document where the text paragraphs will be rendered and adds a note explaining the sample at the top of the first page: const int margin = 36 The complete example and code are included in the updated sample explorer for GrapeCity Documents for PDF. This example reads an existing multi-page PDF document and shows how to use ITextMap.Paragraphs to extract paragraphs from each page of a PDF document.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |