Testimonials


Been a self employed software engineer myself, i cannot tell you enough how i appreciate your professionalism and your work.

Keep up this more than excellent work, i hope every potential customer really gives you the credits you deserve and quickly becomes a new, very satified customer. It is the best investment for their money they can make and never ever regret it.

Yannis Sferopoulos
Opendata Ltd





VintaSoftPDF.NET Plug-in - FAQ

General questions:

 

Redistribution:

 

Sales:

 

PDF:

 

Programming:

 

 

For which purposes can I use the VintaSoftPDF.NET Plug-in?

You can use VintaSoftPDF.NET as plug-in for VintaSoftImaging.NET SDK and it'll allow you display, render, create, convert, annotate, print, save, manipulate and edit pages of PDF files.

 

 

From which parts does the plug-in consist?

The library contains:

  • Vintasoft.PDF.dll assembly - a 100% .NET assembly
  • Documentation in CHM format (VintaSoft.Imaging.chm file)
  • Examples for MS Visual Basic.NET, MS Visual C#, ASP.NET (files in the Examples directory)
  • Demo applications (files in Bin\v2.0 directory)

 

 

In which programming languages can I use the plug-in?

With Single Developer license or Site license you can use component in:

  • Microsoft Visual Studio .NET : Visual Basic, Visual C#, Visual C++, Visual J#
  • Borland Delphi 8.0, Borland C# Builder, Borland C++ BuilderX
  • any other languages which are compatible with .NET Framework.

With Server license you can use component in:

  • Intranet / internet applications on a server-side (ASP.NET or PHP)

 

 

What restrictions does the unregistered version contain?

Unregistered version has the following restrictions:

  • nag screen
  • watermark
  • change of some PDF file tags disabled
  • 128-bit encryption disabled in writer

All these restrictions are removed in registered version.

 

 

I have problems. What should I do?

Answers to the majority of questions can be found in the documentation or this web site. Please write to our support team to get more help.

 

 

What files do I need to include in the setup package of my program?

You need include two files: VintaSoft.Imaging.dll and Vintasoft.PDF.dll. These files must be placed in the same folder as the assembly that references them. Make sure that the version you distribute is the version your assembly was compiled with.

 

 

Can I re-distribute Vintasoft.PDF.dll with my application without royalties?

Yes, this component is royalty free. You pay only for registration one time.

Only Vintasoft.PDF.dll can be re-distributed with your application. Site license has no limitations in re-distribution. Single Developer license has limitation in re-distribution. Server license is not royalty free. Please read the license agreement for more information.

 

 

What to do when my Single developer license application redistribution count is about to exceed 100 copies in a year?

If you own Single developer license you must contact Sales in an event your application redistribution count is about to exceed 100 copies in current year. You'll be provided with an opportunity to upgrade your Single developer license to Site license with 30% discount or to buy additional Single developer license.

 

 

What is the difference between Single developer license and Site license?

  • Single developer license must be used in software development by only one programmer whose name is indicated in the license data.
  • Site license must be used in software development by any programmer who works for a company which name is indicated in the license data.
  • Single developer license may be used in software development on any PC located at any physical address.
  • Site license may be used in software development on any PC located at single physical address (at only one office).
  • Single developer license permits a royalty free distribution of an application which integrates the SDK redistributable assemblies up to 100 copies in a year.
  • Site license permits an unlimited royalty free distribution of an application which integrates the SDK redistributable assemblies.

 

 

Is there a difference in deploying my application on a desktop PC or on a server?

Yes, there is. Please read the "Deploying" section in this product documentation to understand the difference.

Terms: Desktop PC - Windows XP, Vista, 7 OS installed. Server - Windows Server 2000, 2003, 2008 OS installed.

 

 

I cannot open PDF file using your library. What should I do?

Please send us your "bad" file. We will analyze it and update our reading algorithm if the image is correct.

 

 

PDF document is displayed incorrectly. What should I do?

It's possible that while a page was generated:

  • error occur
  • warning appear
  • page contain unsupported elements

Error (PDFRuntimeError): appear when there was an attempt to draw unsupported element (e.g. JPEG2000 image), or an internal error occur in the library. Errors at page elements drawing indicate that the page was drawn incorrectly.

Warning (PDFRuntimeWarning): appear when there were used unsupported color correction functions (e.g. ICCProfile). The warning means that the element has been completely drawn, but this color correction function did not apply.

In the current version of library are unsupported:

  • Fonts: MMType1; OpenType
  • ShadingPatterns: TensorProductPatchMesh; CoonsPatchMesh
  • ColorCorrection: ICCProfile; Rendering Intents

Errors and warnings may also occur during saving a file to PDF/A.

To find out whether the document was drawn correctly (are there any unsupported elements or occur errors), it is necessary to use the property PDFDocument.RuntimeMessages. Here is an example of code to calculate the errors / warnings in the document:

[VB.NET]
Public Shared Sub TestDocument(ByVal fileName As String, ByRef errors As Integer, _
                                                         ByRef warnings As Integer)
    ' open document
    Dim document As New PdfDocument(fileName)
    errors = 0
    warnings = 0
    For i As Integer = 0 To document.Pages.Count - 1
        ' clear messages
        document.RuntimeMessages.Clear()
        ' renderer page
        Dim pageImage As VintasoftImage = document.Pages(i).Render()
        pageImage.Dispose()
        ' check messages
        For Each message As PdfRuntimeMessage In document.RuntimeMessages
            If TypeOf message Is PdfRuntimeWarning Then
                warnings += 1
            ElseIf TypeOf message Is PdfRuntimeError Then
                errors += 1
            End If
        Next
    Next
End Sub

[C#]
public static void TestDocument(string fileName, out int errors, out int warnings)
{
    // open document
    PdfDocument document = new PdfDocument(fileName);
    errors = 0;
    warnings = 0;
    for (int i = 0; i < document.Pages.Count; i++)
    {
        // clear messages
        document.RuntimeMessages.Clear();
        // render the page
        VintasoftImage pageImage = document.Pages[i].Render();
        pageImage.Dispose();
        // check messages
        foreach (PdfRuntimeMessage message in document.RuntimeMessages)
        {
            if (message is PdfRuntimeWarning)
                warnings++;
            else if (message is PdfRuntimeError)
                errors++;
        }
    }
}

If the document was drawn with error, but the library has not reported about this error, or if an error occur and it is not related with unsupported elements — send your PDF document to VintaSoft support team for further review and debugging.

 

 

How do I pack PDF document?

Packing (PDFDocument.Pack) allows:

  • remove unusable objects from document
  • change version of PDF file (e.g. convert to PDF/A)
  • specify usage of Cross-Reference tables compression (from version 1.5 of PDF specification)
  • specify usage of text filters for binary data

Usage of PDFDocument.Optimize functions allows to set a way of compression for different objects: color images, black-and-white images, data. Before the end of work the Optimize function will call the pack function.

Here is an example that shows how to pack PDF file (optimize=false) or how to pack PDF file and convert all color images to JPEG (optimize=true):

[VB.NET]
Public Shared Sub PackPdf(ByVal pdfFileName As String, ByVal optimize As Boolean)
    ' open PDF document to Read/Write
    Dim pdfDocument As New PdfDocument(pdfFileName)
    ' create PdfFormat - 1.6 format, with compressed coross-reference table
    Dim format As New PdfFormat("1.6", True, True)
    If optimize Then
        ' set JPEG Quality to 80
        PdfCompressionSettings.DefaultSettings.JpegQuality = 80
        ' create optimize settings
        ' compression for Color images - JPEG
        ' compression for B/W images - not change
        Dim optimizeSettings As New PdfOptimizeSettings(PdfCompression.Jpeg, _
                                                        PdfCompression.Undefined, _
                                                        PdfCompression.Undefined)
        ' compression for Data - not change
        ' optimize and Pack document
        pdfDocument.Optimize(format, optimizeSettings)
    Else
        ' pack document
        pdfDocument.Pack(format)
    End If
    ' free resources
    pdfDocument.Dispose()
End Sub

[C#]
public static void PackPdf(string pdfFileName, bool optimize)
{
    // open PDF document to Read/Write
    PdfDocument pdfDoument = new PdfDocument(pdfFileName);
    // create PdfFormat - 1.6 format, with compressed cross-reference table
    PdfFormat format = new PdfFormat("1.6", true, true);
    if (optimize)
    {
        // set JPEG Quality to 80
        PdfCompressionSettings.DefaultSettings.JpegQuality = 80;
        // create optimize settings
        PdfOptimizeSettings optimizeSettings = new PdfOptimizeSettings(
            PdfCompression.Jpeg,       //compression for Color images - JPEG
            PdfCompression.Undefined,  //compression for B/W images - not changed
            PdfCompression.Undefined); //compression for Data - not changed
        // optimize and Pack document
        pdfDoument.Optimize(format, optimizeSettings);
    }
    else
    {
        // pack document
        pdfDoument.Pack(format);
    }
    // free resources
    pdfDoument.Dispose();
}

 

 

What should I do when there is no font found?

Font search algorithm by default is as follows: the search starts in the directory $ASSEMBLY_DIRECTORY$\Fonts\, if there is no font found it begins to search the fonts installed in the system (information from the registry).

When the font was not found you should place it in the directory $ASSEMBLY_DIRECTORY$\Fonts\ or install to the system. You must also take into account that the search occur by the font's common name, not in PostScript style.

If you want redefine the font search algorithm, then you must create an implementation of IfontProgramsController interface or an inheritor from any implementation of this interface (SystemFontProgramsController, UserAndSystemFontProgramsController). After it is necessary to initialize property PDFDocument.FontProgramsController using an instance of created by you class.

 

 

How to convert PDF to TIFF?

Here is an example that shows how to convert PDF document to TIFF file using image collection and TiffEncoder:

[VB.NET]
Public Shared Sub ConvertPdfToTiff_1(ByVal pdfFileName As String, _
                                     ByVal tiffFileName As String)
    ' create ImageCollection
    Dim imageCollection As New ImageCollection()
    ' add PDF document to collecion
    imageCollection.Add(pdfFileName)
    ' create TiffEncoder
    Dim tiffEncoder As New TiffEncoder(True)
    ' set TIFF compression to Zip
    tiffEncoder.Compression = TiffCompression.Zip
    ' save pages use TIFF encoder
    imageCollection.SaveSync(tiffFileName, tiffEncoder)
    ' free resources
    tiffEncoder.Dispose()
    imageCollection.Dispose()
End Sub

[C#]
public static void ConvertPdfToTiff_1(string pdfFileName, string tiffFileName)
{
    // create ImageCollection
    ImageCollection imageCollection = new ImageCollection();
    // add PDF document to collecion
    imageCollection.Add(pdfFileName);
    // create TiffEncoder
    TiffEncoder tiffEncoder = new TiffEncoder(true);
    // set TIFF compression to Zip
    tiffEncoder.Compression = TiffCompression.Zip;
    // save pages using TIFF encoder
    imageCollection.SaveSync(tiffFileName, tiffEncoder);
    // free resources
    tiffEncoder.Dispose();
    imageCollection.Dispose();
}

Here is an example that shows how to convert PDF document to TIFF file using PdfDocument and TiffFile:

[VB.NET]
Public Shared Sub ConvertPdfToTiff_2(ByVal pdfFileName As String, _
                                     ByVal tiffFileName As String)
    ' open PDF document
    Dim pdfDocument As New PdfDocument(pdfFileName)
    ' create TIFF File
    Dim tiffFile As New TiffFile(tiffFileName, True)
    ' set TIFF compression to Zip
    tiffFile.Compression = TiffCompression.Zip
    ' foreach PDF pages
    For i As Integer = 0 To pdfDocument.Pages.Count - 1
        ' in TiffFile add rendered PDF page
        tiffFile.Pages.Add(pdfDocument.Pages(i).Render())
    Next
    ' free resources
    pdfDocument.Dispose()
    tiffFile.Dispose()
End Sub

[C#]
public static void ConvertPdfToTiff_2(string pdfFileName, string tiffFileName)
{
    // open PDF document
    PdfDocument pdfDocument = new PdfDocument(pdfFileName);
    // create TIFF File
    TiffFile tiffFile = new TiffFile(tiffFileName, true);
    // set TIFF compression to Zip
    tiffFile.Compression = TiffCompression.Zip;
    // for each PDF pages
    for (int i = 0; i < pdfDocument.Pages.Count; i++)
    {
        // add rendered PDF page to TiffFile
        tiffFile.Pages.Add(pdfDocument.Pages[i].Render());
    }
    // free resources
    pdfDocument.Dispose();
    tiffFile.Dispose();
}

 

 

How to convert PDF to TIFF with defined resolution (dpi)?

Here is an example that shows how to convert PDF document to TIFF file (with defined resolution and given drawing parameters) using image collection and PdfEncoder:

[VB.NET]
Public Shared Sub ConvertPdfToTiffDPI_1(ByVal pdfFileName As String, _
                                        ByVal tiffFileName As String, _
                                        ByVal dpi As Single)
    ' create ImageCollection    
    Dim imageCollection As New ImageCollection()
    ' set rendering settings
    imageCollection.RenderingSettings = New RenderingSettings(dpi, dpi,_
      System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear,_
      System.Drawing.Drawing2D.SmoothingMode.AntiAlias)
    ' add PDF document to collecion
    imageCollection.Add(pdfFileName)
    ' create TiffEncoder
    Dim tiffEncoder As New TiffEncoder(True)
    ' set TIFF compression to Zip
    tiffEncoder.Compression = TiffCompression.Zip
    ' save pages use TIFF encoder
    imageCollection.SaveSync(tiffFileName, tiffEncoder)
    ' free resources
    tiffEncoder.Dispose()
    imageCollection.Dispose()
End Sub

[C#]
public static void ConvertPdfToTiffDPI_1(string pdfFileName, string tiffFileName, 
                                                                       float dpi)
{
    // create ImageCollection  
    ImageCollection imageCollection = new ImageCollection();
    // set rendering settings
    imageCollection.RenderingSettings = new RenderingSettings(
        dpi, 
        dpi, 
        System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear, 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias);
    // add PDF document to collecion
    imageCollection.Add(pdfFileName);
    // create TiffEncoder
    TiffEncoder tiffEncoder = new TiffEncoder(true);
    // set TIFF compression to Zip
    tiffEncoder.Compression = TiffCompression.Zip;
    // save pages using TIFF encoder
    imageCollection.SaveSync(tiffFileName, tiffEncoder);
    // free resources
    tiffEncoder.Dispose();
    imageCollection.Dispose();
}

Here is an example that shows how to convert PDF document to TIFF file (with defined resolution and given drawing parameters) using PdfDocument and TiffFile:

[VB.NET]
Public Shared Sub ConvertPdfToTiffDPI_2(ByVal pdfFileName As String, ByVal tiffFileName _
                                                          As String, ByVal dpi As Single)
    ' open PDF document
    Dim pdfDocument As New PdfDocument(pdfFileName)
    ' set resolution
    pdfDocument.RenderingSettings.Resolution = New Resolution(dpi, dpi)
    ' set rendering mode - optimal balance between rendering speed and rendering quality.
    pdfDocument.RenderingSettings.RenderingMode = PdfRenderingMode.Normal
    ' create TIFF File
    Dim tiffFile As New TiffFile(tiffFileName, True)
    ' set TIFF compression to Zip
    tiffFile.Compression = TiffCompression.Zip
    ' foreach PDF pages
    For i As Integer = 0 To pdfDocument.Pages.Count - 1
        ' in TiffFile add rendered PDF page
        tiffFile.Pages.Add(pdfDocument.Pages(i).Render())
    Next
    ' free resources
    pdfDocument.Dispose()
    tiffFile.Dispose()
End Sub

[C#]
public static void ConvertPdfToTiffDPI_2(string pdfFileName, string tiffFileName, float dpi)
{
    // open PDF document
    PdfDocument pdfDocument = new PdfDocument(pdfFileName);
    // set resolution
    pdfDocument.RenderingSettings.Resolution = new Resolution(dpi, dpi);
    // set rendering mode - optimal balance between rendering speed and rendering quality.
    pdfDocument.RenderingSettings.RenderingMode = PdfRenderingMode.Normal;
    // create TIFF File
    TiffFile tiffFile = new TiffFile(tiffFileName, true);
    // set TIFF compression to Zip
    tiffFile.Compression = TiffCompression.Zip;
    // for each PDF pages
    for (int i = 0; i < pdfDocument.Pages.Count; i++)
    {
        // add rendered PDF page to TiffFile
        tiffFile.Pages.Add(pdfDocument.Pages[i].Render());
    }
    // free resources
    pdfDocument.Dispose();
    tiffFile.Dispose();
}

 

 

How to convert TIFF to PDF?

Here is an example that shows how to convert TIFF file to PDF document using image collection and PdfEncoder:

[VB.NET]
Public Shared Sub ConvertTiffToPdf_1(ByVal tiffFileName As String, _
                                     ByVal pdfFileName As String)
    ' create ImageCollection
    Dim imageCollection As New ImageCollection()
    ' add PDF document to collecion
    imageCollection.Add(tiffFileName)
    ' create TiffEncoder
    Dim pdfEncoder As New PdfEncoder(True)
    ' set PDF compression to Zip
    pdfEncoder.Settings.Compression = PdfImageCompression.Zip
    ' save pages use PDF encoder
    imageCollection.SaveSync(pdfFileName, pdfEncoder)
    ' free resources
    pdfEncoder.Dispose()
    imageCollection.Dispose()
End Sub

[C#]
public static void ConvertTiffToPdf_1(string tiffFileName, string pdfFileName)
{
    // create ImageCollection
    ImageCollection imageCollection = new ImageCollection();
    // add TIFF file to collecion
    imageCollection.Add(tiffFileName);
    // create TiffEncoder
    PdfEncoder pdfEncoder = new PdfEncoder(true);
    // set PDF compression to Zip
    pdfEncoder.Compression = PdfImageCompression.Zip;
    // save pages using PDF encoder
    imageCollection.SaveSync(pdfFileName, pdfEncoder);
    // free resources
    pdfEncoder.Dispose();
    imageCollection.Dispose();
}

Here is an example that shows how to convert TIFF file to PDF document using PdfDocument and TiffFile:

[VB.NET]
Public Shared Sub ConvertTiffToPdf_2(tiffFileName As String, pdfFileName As String)
    ' cache size, in bytes (10MB)
    Dim cacheSize As Integer = 10 * 1024 * 1024

    ' unsaved image data size
    Dim imageDataSize As Integer = 0

    ' create TIFF File
    Dim tiffFile As New TiffFile(tiffFileName)
    ' create new PdfDocument, version 1.4
    Dim pdfDocument As New PdfDocument(pdfFileName, FileMode.Create, FileAccess.Write, PdfFormat.Pdf_14)
    ' for each TIFF page
    For i As Integer = 0 To tiffFile.Pages.Count - 1
        ' add TIFF page to PDF document
        Dim newPage As PdfPage
        Using pageImage As VintasoftImage = tiffFile.Pages(i).GetImage()
            newPage = pdfDocument.Pages.Add(pageImage, PdfCompression.Zip)
        End Using

        ' increment image data size
        imageDataSize += newPage.ImagesSize
        
        ' drop changes to disk if need
        If imageDataSize > cacheSize Then
             pdfDocument.SaveChanges()
             imageDataSize = 0
        End If
    Next
    ' free resources
    pdfDocument.Dispose()
    tiffFile.Dispose()
End Sub

[C#]
public static void ConvertTiffToPdf_2(string tiffFileName, string pdfFileName)
{
    // cache size, in bytes (10MB)
    int cacheSize = 10 * 1024 * 1024;

    // unsaved image data size
    int imageDataSize = 0;
    
    // create TIFF File
    TiffFile tiffFile = new TiffFile(tiffFileName);
    // create new PdfDocument, version 1.4
    PdfDocument pdfDocument = new PdfDocument(
        pdfFileName,
        FileMode.Create,
        FileAccess.Write,
        PdfFormat.Pdf_14);
    // for each TIFF page
    for (int i = 0; i < tiffFile.Pages.Count; i++)
    {
        // add TIFF page to PDF document
        PdfPage newPage;
        using (VintasoftImage pageImage = tiffFile.Pages[i].GetImage())
            newPage = pdfDocument.Pages.Add(pageImage, PdfCompression.Zip);
        
        // increment image data size
        imageDataSize += newPage.ImagesSize;

        // drop changes to disk if need
        if (imageDataSize > cacheSize)
        {
            pdfDocument.SaveChanges();
            imageDataSize = 0;
        }
    }
    // free resources
    pdfDocument.Dispose();
    tiffFile.Dispose();
}

 

 

How to convert TIFF to PDF/A?

Here is an example that shows how to convert TIFF file to PDF/A document using image collection and PdfEncoder:

[VB.NET]
Public Shared Sub ConvertTiffToPdfA_1(ByVal tiffFileName As String, _
                                      ByVal pdfFileName As String)
    ' create ImageCollection
    Dim imageCollection As New ImageCollection()
    ' add PDF document to collecion
    imageCollection.Add(pdfFileName)
    ' create TiffEncoder
    Dim pdfEncoder As New PdfEncoder(True)
    ' set PDF compression to Zip
    pdfEncoder.Settings.Compression = PdfImageCompression.Zip
    ' set PDF/A compatible
    pdfEncoder.Settings.PdfACompatible = True
    ' save pages use PDF encoder
    imageCollection.SaveSync(tiffFileName, pdfEncoder)
    ' free resources
    pdfEncoder.Dispose()
    imageCollection.Dispose()
End Sub

[C#]
public static void ConvertTiffToPdfA_1(string tiffFileName, string pdfFileName)
{
    // create ImageCollection
    ImageCollection imageCollection = new ImageCollection();
    // add PDF document to collection
    imageCollection.Add(pdfFileName);
    // create TiffEncoder
    PdfEncoder pdfEncoder = new PdfEncoder(true);
    // set PDF compression to Zip
    pdfEncoder.Compression = PdfImageCompression.Zip;
    // set PDF/A compatible
    pdfEncoder.PdfACompatible = true;
    // save pages using PDF encoder
    imageCollection.SaveSync(tiffFileName, pdfEncoder);
    // free resources
    pdfEncoder.Dispose();
    imageCollection.Dispose();
}

Here is an example that shows how to convert TIFF file to PDF/A document using PdfDocument and TiffFile:

[VB.NET]
Public Shared Sub ConvertTiffToPdfA_2(ByVal tiffFileName As String, _
                                      ByVal pdfFileName As String)
    ' create TIFF File
    Dim tiffFile As New TiffFile(tiffFileName)
    ' create new PDF/A compatible PdfDocument
    Dim pdfDocument As New PdfDocument(pdfFileName, FileMode.Create, FileAccess.Write, _
                                                                      PdfFormat.Pdf_A)
    ' foreach TIFF pages
    For i As Integer = 0 To tiffFile.Pages.Count - 1
        ' add TIFF page to PDF document
        pdfDocument.Pages.Add(tiffFile.Pages(i).GetImage(), PdfCompression.Zip)
        ' drop changes to disk
        pdfDocument.SaveChanges()
    Next
    ' free resources
    pdfDocument.Dispose()
    tiffFile.Dispose()
End Sub

[C#]
public static void ConvertTiffToPdfA_2(string tiffFileName, string pdfFileName)
{
    // create TIFF File
    TiffFile tiffFile = new TiffFile(tiffFileName);
    // create new PDF/A compatible PdfDocument
    PdfDocument pdfDoument = new PdfDocument(
        pdfFileName, 
        FileMode.Create, 
        FileAccess.Write, 
        PdfFormat.Pdf_A);
    // for each TIFF page
    for (int i = 0; i < tiffFile.Pages.Count; i++)
    {
        // add TIFF page to PDF document
        pdfDocument.Pages.Add(tiffFile.Pages[i].GetImage(), PdfCompression.Zip);
        // drop changes to disk
        pdfDocument.SaveChanges();
    }
    // free resources
    pdfDocument.Dispose();
    tiffFile.Dispose();
}

 

 

How to extract text from PDF page?

Here is a simple code:

[VB.NET]
Public Shared Function ExtractTextFromPdfPage(ByVal document As PdfDocument, _
                                              ByVal pageIndex As Integer) As String
    Return document.Pages(pageIndex).TextRegion.TextContent
End Function

[C#]
public static string ExtractTextFromPdfPage(PdfDocument document, int pageIndex)
{
    return document.Pages[pageIndex].TextRegion.TextContent;
}

 

 

How to find text on PDF page?

Here is a simple code:

[VB.NET]
Public Shared Function FindTextOnPdfPage(ByVal document As PdfDocument, _
                                         ByVal pageIndex As Integer, _
                                         ByVal text As String) As TextRegion
    ' creates find options
    Dim findOptions As FindTextOptions = New FindTextOptions()
    ' non case sensitive text must be searched
    findOptions.MathCase = False
    ' find text
    Dim startIndex As Integer = 0
    Return document.Pages(pageIndex).TextRegion.FindText(text, startIndex, _
                                                               findOptions)
End Function

[C#]
public static TextRegion FindTextOnPdfPage(PdfDocument document, int pageIndex, 
                                                                   string text)
{
    // creates find options
    FindTextOptions findTextOptions = new FindTextOptions();
    // non case sensitive text must be searched
    findTextOptions.MathCase = false;
    // find text
    int startIndex = 0;
    return document.Pages[pageIndex].TextRegion.FindText(text, ref startIndex, 
                                                             findTextOptions);
}

 

 

How to find and highlight text within a PDF document?

Here is a simple code:

[VB.NET]
Partial Public Class TextSearchForm
  Inherits Form
  '...
  Private _viewerTool As PdfViewerTool
  Private _imageViewer As ImageViewer
  '...
  Public Sub New()
     '...
     ' creates the PdfViewerTool instance
     _viewerTool = New PdfViewerTool(_imageViewer, New _
                   SolidBrush(Color.FromArgb(56, Color.Blue)))
     ' subscribe to viewer tool events
     AddHandler _viewerTool.TextSearched, AddressOf _viewerTool_TextSearched
     ' sets the PDF viewer tool as current tool
     _imageViewer.CurrentTool = _viewerTool
  End Sub

  ' Search the text starts with a current page.
  Public Sub SearchText(ByVal text As String, ByVal newSearch As Boolean)
     ' creates find options
     Dim findTextOptions As FindTextOptions = New FindTextOptions()
     ' non case sensitive text must be searched
     findTextOptions.MathCase = False
     ' find text at all pages
     If newSearch Then
        _viewerTool.FindText(text, PdfViewerTool.FindTextMode.AllPages, _
                                                       findTextOptions)
     Else
        _viewerTool.FindTextNext(text, PdfViewerTool.FindTextMode.AllPages, _
                                                           findTextOptions)
     End If
  End Sub

  ' PdfViewerTool.FindTextFinished event handler.
  Private Sub _viewerTool_TextSearched(ByVal sender As Object, _
                                       ByVal e As PdfTextSearchedEventArgs)
     If e.FoundTextRegion Is Nothing Then
        ' text was not found
        MessageBox.Show(String.Format("The following specified text was not found: {0}", _
                                                                       e.SearchingText))
     Else
        ' text was found
        ' set focused page
        _imageViewer.FocusedIndex = e.PageIndex
        ' select text region
        _viewerTool.SelectedRegion = e.FoundTextRegion
     End If
  End Sub
End Class

[C#]
public partial class TextSearchForm : Form
{
    //...
    ImageViewer _imageViewer = null;
    PdfViewerTool _viewerTool = null;

    //...
    public TextSearchForm()
    {
        //...
        // creates the PdfViewerTool instance
        _viewerTool = new PdfViewerTool(_imageViewer, new SolidBrush(
                                        Color.FromArgb(56, Color.Blue)));
        // subscribe to viewer tool events
        _viewerTool.TextSearched += new EventHandler(
                                                     _viewerTool_TextSearched);
        // sets the PDF viewer tool as current tool
        _imageViewer.CurrentTool = _viewerTool;
    }

    // Search the text starts with a current page.
    public void SearchText(string text, bool newSearch)
    {
        // creates find options
        FindTextOptions findTextOptions = new FindTextOptions();
        // non case sensitive text must be searched
        findTextOptions.MathCase = false;
        // find text at all pages
        if (newSearch)
            _viewerTool.FindText(text, PdfViewerTool.FindTextMode.AllPages, 
                                                          findTextOptions);
        else
            _viewerTool.FindTextNext(text, PdfViewerTool.FindTextMode.AllPages, 
                                                              findTextOptions);
    }
 
    // PdfViewerTool.FindTextFinished event handler.
    void _viewerTool_TextSearched(object sender, PdfTextSearchedEventArgs e)
    {
        if (e.FoundTextRegion == null)
        {
            // text was not found
            MessageBox.Show(string.Format("The following specified text was not found: {0}", 
                                                                          e.SearchingText));
        }
        else
        {
            // text was found
            // set focused page
            _imageViewer.FocusedIndex = e.PageIndex;
            // select text region
            _viewerTool.SelectedRegion = e.FoundTextRegion;
        }
    }
}