О продукте
ЗагрузитьОтзывыBeen a self employed software engineer myself, i cannot tell you enough how i appreciate your professionalism and your work. Yannis Sferopoulos |
VintaSoftPDF.NET Plug-in - FAQОбщие вопросы:
Распространение:
Продажи:
PDF:
Программирование:
Для каких целей я могу использовать VintaSoftPDF.NET Plug-in?VintaSoftPDF.NET является встраиваемым модулем библиотеки VintaSoftImaging.NET и может использоваться для визуализации, рендеринга, создания, конвертации, аннотирования, печати, сохранения, манипуляции и обработки страниц файлов формата PDF.
Что включает в себя данный Plug-in?Библиотека включает в себя:
В каких языках программирования я могу использовать этот компонент?Лицензия разработчика и лицензия для компании позволяют использовать компонент в:
Лицензия для сервера позволяет использовать компонент в:
Какие ограничения имеет незарегистрированная версия библиотеки?Незарегистрированная версия имеет следующие ограничения в использовании:
Все эти ограничения отсутствуют в зарегистрированной версии.
Я не нашел ответа на свой вопрос. Что мне делать?Информация по большинству вопросов может быть найдена в документации или в этом FAQ. Если Вы не нашли ответа на свой вопрос, тогда напишите письмо в службу технической поддержки.
Какие файлы мне нужно включать в дистрибутив моей программы?Вам нужно включить в дистрибутив Вашей программы два файла: VintaSoft.Imaging.dll и Vintasoft.PDF.dll. При установке Вашей программы эти файлы должны быть помещены в каталог на который была ссылка при компиляции программы.
Могу ли я распространять компонент вместе с моим приложением без какой либо дополнительной оплаты?Да, Вы можете распространять компонент вместе со своим приложением. Вы платите только за первоначальную регистрацию. Только файл Vintasoft.PDF.dll может распространяться с Вашим приложением. Лицензия для компании не имеет ограничений в распространении. Лицензия для разработчика имеет некоторые ограничения в распространении. Распространение с Лицензией для сервера требует оплаты для каждого сервера. Пожалуйста, читайте лицензионное соглашение.
Что делать если распространение моей программы, созданной на основе Лицензии для разработчика, может превысить 100 копий в текущем году?Если Вы обладаете Лицензией для разработчика и распространение Вашей программы может превысить 100 копий в текущем году, Вам необходимо обратиться в Отдел продаж "ВинтаСофт", где Вам будет предоставлена возможность апгрейда до Лицензии для организации со скидкой 30% или предложено купить дополнительную Лицензию для разработчика.
Каковы различия между Лицензией для разработчика и Лицензией для организации?
Есть ли разница в использовании моего приложения на настольном ПК или на сервере?Да, есть. Пожалуйста, прочитайте раздел "Deploying" в документации этого продукта, чтобы понять в чем разница. Термины: Desktop PC - установлена ОС Windows XP, Vista, 7. Server - установлена ОС Windows Server 2000, 2003, 2008.
Я не могу открыть PDF файл. Что мне делать?Пожалуста пришлите нам "плохой" файл. Мы его проанализируем и обновим алгоритм чтения файлов, если изображение является корректным.
PDF документ отображается неверно. Что делать?Возможно во время генерации страницы:
Ошибка (PDFRuntimeError) - возникает когда произошла попытка отрисовать элемент неподдерживаемый библиотекой (например попыка отрисовать изображение формата JPEG2000), либо произошла ошибка в самой библиотеке. Наличие ошибок при отрисовке страницы говорит о том что страница была отрисована неправильно. Предупреждение (PDFRuntimeWarning) - возникает когда элемент отрисован полностью, но не применены функции корректировки цвета которые не поддерживаются билиотекой (например ICCProfile). В текущей версии библиотеки не поддерживается:
Ошибки и предупреждения могут возникать также при операции сохранения файла в PDF/A. Для того чтобы узнать правильно ли отрисован документ(есть ли не поддерживаемые элементы или возникли ошибки) необходимо обратиться к свойству PDFDocument.RuntimeMessages. Приведем пример кода для подсчета ошибок/предупреждений в документе:
[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++;
}
}
}
Если документ отрисовался с ошибкой, но библиотека не сообщила об ошибке, либо если произошла ошибка не связанная с неподдерживаемыми элементами — отправьте ваш PDF документ в службу поддержки ВинтаСофт для дальнейшего изучения и устранения данной ошибки.
Как упаковать PDF документ?Упаковка (PDFDocument.Pack) позволяет:
Использование функции PDFDocument.Optimize позволяет задать способ сжатия для разных объектов: цветных изображений, черно-белых изображений, данных. Перед окончанием работы функция Optimize вызовет функцию упаковки. Вот пример показывающий как упаковать PDF файл (optimize=false), либо как упаковать PDF файл и при этом конвертировать все цветные изображения в 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();
}
Что делать если не найден шрифт?По умолчанию алгоритм поиска шрифта следующий: поиск шрифта начинается в директории $ASSEMBLY_DIRECTORY$\Fonts\, если там не найден далее идет поиск среди шрифтов установленных в системе (информация из реестра). То есть если шрифт небыл найден его необходимо поместить в директорию $ASSEMBLY_DIRECTORY$\Fonts\ либо установить в систему. Также необходимо учитывать что по умолчанию поиск шрифта происходит по их обычным именам, а не по именам в стиле PostScript. Если вы хотите переопределить алгоритм поиска шрифтов, то вам необходимо создать реализацию интерфейса IfontProgramsController, либо наследника от любой реализации данного интерфейса (SystemFontProgramsController, UserAndSystemFontProgramsController). Далее необходимо инициализировать свойсво PDFDocument.FontProgramsController экземпляром созданного вами класса.
Как сконвертировать PDF в TIFF?Вот пример показывающий как сконвертировать PDF документ в TIFF файл с помощью коллекции изображений и 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();
}
Вот пример показывающий как сконвертировать PDF документ в TIFF файл с помощью PDFDocument и 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();
}
Как сконвертировать PDF в TIFF в нужном разрешении (dpi)?Вот пример показывающий как сконвертировать PDF документ в Tiff файл (в нужном разрешении и с заданными параметрами отрисовки) используя коллекцию изображений и 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();
}
Вот пример показывающий как сконвертировать PDF документ в Tiff файл (в нужном разрешении и с заданными параметрами отрисовки) используя PDFDocument и 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();
}
Как сконвертировать TIFF в PDF?Вот пример показывающий как сконвертировать Tiff файл в PDF документ с помощью коллекции изображений и 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();
}
Вот пример показывающий как сконвертировать Tiff файл в PDF документ используя PDFDocument и 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();
}
Как сконвертировать TIFF в PDF/A?Вот пример показывающий как сконвертировать Tiff файл в PDF/A документ используя коллекцию изображений и 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();
}
Вот пример показывающий как сконвертировать Tiff файл в PDF/A документ используя PDFDocument и 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();
}
Как получить текст из страницы PDF документа?Вот пример:
[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;
}
Как найти текст на странице PDF документа?Вот пример:
[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);
}
Как найти и выделить текст в PDF документе?Вот пример:
[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
|