LEADTOOLS PDF (Leadtools.Pdf assembly)
LEAD Technologies, Inc

PDFTextProperties Structure

Example 





Members 
Contains information on a text item in a PDF page.
Object Model
PDFTextProperties Structure
Syntax
[SerializableAttribute()]
public struct PDFTextProperties : System.ValueType 
'Declaration
 
<SerializableAttribute()>
Public Structure PDFTextProperties 
   Inherits System.ValueType
'Usage
 
Dim instance As PDFTextProperties
[SerializableAttribute()]
public class PDFTextProperties
JAVASCRIPT_NOSTRUCTS
[SerializableAttribute()]
public value class PDFTextProperties : public System.ValueType 
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
 
Public Sub PDFTextPropertiesExample()
      Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD.pdf")
      Dim txtFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_txt.txt")

      ' Create a PDF document for file
      Using document As New PDFDocument(pdfFileName)

         ' Parse the text of all the pages
         document.ParsePages(PDFParsePagesOptions.Fonts Or PDFParsePagesOptions.Objects Or PDFParsePagesOptions.Fonts, 1, -1)

         ' Output the words to the txt file
         Using writer As StreamWriter = File.CreateText(txtFileName)
            For Each page As PDFDocumentPage In document.Pages
               Dim line As New StringBuilder()
               For Each obj As PDFObject In page.Objects
                  If obj.ObjectType = PDFObjectType.Text Then
                     line.Append(obj.Code)

                     If obj.TextProperties.IsEndOfLine Then
                        writer.WriteLine(line)

                        line = New StringBuilder()
                     End If
                  End If
               Next
            Next
         End Using
      End Using
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PDFTextPropertiesExample()
   {
      string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD.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 | PDFParsePagesOptions.Fonts, 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:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PDFTextProperties Members
Leadtools.Pdf Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.