←Select platform

PDFTextProperties Structure

Summary
Contains information about a text item in a PDF page.
Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
public struct PDFTextProperties 
public class PDFTextProperties 
[SerializableAttribute()] 
public value class PDFTextProperties : public System.ValueType  
class PDFTextProperties: 
Remarks

The PDFTextProperties structure is used as the type of the following properties:

This structure contains font information of the text such as its font width, height and index, text position(represent whether the text item is the last item in a word or a line) and the text color.

Example

This example reads the objects of a PDF file and creates a file on disk containing the text of the file. For an example that draws the PDF to an image, refer to PDFObject.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Pdf; 
using Leadtools.WinForms; 
using Leadtools.Drawing; 
 
 
public void PDFTextPropertiesExample() 
{ 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string txtFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_txt.txt"); 
 
   // Create a PDF document for file 
   using (PDFDocument document = new PDFDocument(pdfFileName)) 
   { 
      // Parse the text of all the pages 
      document.ParsePages(PDFParsePagesOptions.Fonts | PDFParsePagesOptions.Objects, 1, -1); 
 
      // Output the words to the txt file 
      using (StreamWriter writer = File.CreateText(txtFileName)) 
      { 
         foreach (PDFDocumentPage page in document.Pages) 
         { 
            StringBuilder line = new StringBuilder(); 
            foreach (PDFObject obj in page.Objects) 
            { 
               if (obj.ObjectType == PDFObjectType.Text) 
               { 
                  line.Append(obj.Code); 
 
                  if (obj.TextProperties.IsEndOfLine) 
                  { 
                     writer.WriteLine(line); 
 
                     line = new StringBuilder(); 
                  } 
               } 
            } 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.