Info del producto
DescargasTestimoniosBeen 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 - FAQCuestiones generales:
Redistribución:
Ventas:
PDF:
Programación:
¿Para qué fines puedo utilizar la VintaSoftPDF.NET Plug-in?VintaSoftPDF.NET es un módulo interpuesto de la biblioteca VintaSoftImaging.NET que puede ser utilizado para la visualización, renderizado, creación, convertación, anotación, impresión, conservación, manipulación y procesamiento de las páginas de files PDF.
¿Qué incluye esta plug-in?La biblioteca incluye:
¿En qué lenguaje de programación puedo utilizar esta plug-in?La licencia del desarrollador y la licencia de la compañía permiten utilizar este componente en:
La licencia del servidor permite utilizar este componente en:
¿Qué límites tiene la versión no registrada de la biblioteca?La versión no registrada tiene las siguientes limitaciones en su utilización:
Todas estas limitaciones están ausentes en la versión registrada.
No he encontrado la respuesta a mi pregunta. ¿Qué debo hacer?Puede encontrar la información sobre la mayoria de las preguntas en la documentación o en este FAQ. Si no ha encontrado la respuesta a su pregunta, escriba al Servicio de apoyo técnico.
¿Qué ficheros debo incluir en distribución de mi programa?Usted debe incluir dos ficheros: VintaSoft.Imaging.dll y Vintasoft.PDF.dll. A la instalación de su programa hay que insertar estos ficheros en el catálogo que tiene la referencia aparecida durante la compilación del programa.
¿Puedo distribuir componente VintaSoftPDF.NET junto con mi aplicación sin algun pago complementario?Si, puede distribuir componente VintaSoftPDF.NET junto con su aplicacion. Paga solamente por el registro inicial. La licencia de la compañía no tiene límites en la distribucion. La licencia del desarrollador tiene ciertos límites en la distribución. La redistribución de la licencia para servidor no es libre de derechos. Por favor, vea el contrato de licencia.
¿Qué hacer si la redistribución de mi aplicación que está creado sobre la base de la licencia del desarrollador puede ser superior 100 copias en el año en curso?Si posee la licencia del desarrollador y redistribución de su aplicación puede ser superior 100 copias en el año en curso, Ud. debe contactar Ventas "VintaSoft". Ud. proveerá de oportunidad actualizar su licencia del desarrollador a la licencia de la compañía con 30% descuento o comprar la segunda licencia del desarrollador.
¿Qué diferencias son entre la licencia del desarrollador y la licencia de la compañía (sitio)?
¿Hay la diferencia en utilizando mi aplicación en Desktop PC o en Server?Si, hay. Por favor lea la sección "Deploying" en documentación de este producto para que comprender la diferencia. Los terminos: Desktop PC – SO Windows XP, Vista, 7 está instalado. Server – SO Windows Server 2000, 2003, 2008 está instalado.
No puedo abrir el archivo PDF usando su biblioteca. ¿Qué debo hacer?Por favor envienos su imagen "mala". Lo analizaremos y actualizaremos nuestro algoritmo de lectura si la imagen es correcta.
Documento PDF se representa incorrectamente. ¿Qué debo hacer?Está posible durante la generación de la página:
Error (PDFRuntimeError) – se aparece cuando ha aparecido la prueba de dibujar un elemento de la biblioteca no apoyada (por ejemplo, una prueba de dibujar la imagen de formato JPEG2000) o ha aparecido un error en la biblioteca misma. Presencia de errores durante dibujo de la página significa que la página fue dibujada erróneamente. Aviso (PDFRuntimeWarning) – se aparece cuando un elemento está dibujando completamente pero sin aplicación de las funciones de correción de color, las cuales no apoya la biblioteca (por ejemplo ICCProfile). En la versión corriente no se apoyan:
Errores y avisos pueden aparecerse también durante la operación de conservación de file PDF/A. Para saber si el documento está dibujado correctamente (si hay elementos apoyados o aparecieron errores) hay que dirigirse a PDFDocument.RuntimeMessages. Aqui se sigue el ejemplo de cálculo de errores/avisos en documento:
[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++;
}
}
}
Si documento fue dibujado con error pero la biblioteca no avisó sobre el error o apareció un error que no refería a elementos no apoyados – envia su documento PDF al Servicio de Apoyo VintaSoft para la examinación y eliminación de presente error.
¿Cómo empaquetar documento PDF?Empaquetamiento (PDFDocument.Pack) permite:
Utilización de la función PDFDocument.Optimize permite indicar el modo de compresión de diferentes objeto: imágenes de color, imágenes de blanco y negro, datos. Antes de terminar el trabajo, la función Optimize llamará la función de empaquetamiento. Aquí hay un ejemplo que muestra como empaquetar file PDF (optimize=false) o como empaquetar file PDF conviertiendo todas las imagenes de color a 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();
}
¿Qué hacer si la letra(font) no fue encontrada?Por omisión, el algoritmo de la busqueda de letra está siguiente: busqueda de letra comienza en directorio $ASSEMBLY_DIRECTORY$\Fonts\, si no se encuentra allá, la busqueda se continua entre letras instaladas en sistema (información de registro). Quiere decir si la letra no fue encontrada, debe ser puesta al directorio $ASSEMBLY_DIRECTORY$\Fonts\ o instalada en sistema. También hay que tener en cuenta, que por omisión la busqueda de letra se realiza por sus nombres ordinarios y no por los nombres en estilo de PostScript. Si quiere determinar de nuevo el algoritmo de busqueda de letras, necesita crear la realización de interface IfontProgramsController o sucesor de cualquier realización de este interface (SystemFontProgramsController, UserAndSystemFontProgramsController). Después, hay que inicializar PDFDocument.FontProgramsController con ejemplo del clase creado por Ud.
¿Cómo convertir PDF a TIFF?Aquí hay un ejemplo que muestra como convertir documento PDF a file TIFF por medio de ImageCollection y 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();
}
Aquí hay un ejemplo que muestra como convertir documento PDF a file TIFF por medio de PDFDocument y 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();
}
¿Cómo convertir PDF a TIFF en resolución necesaria (dpi)?Aquí hay un ejemplo que muestra como convertir PDF documento a TIFF file (en resolución necesaria y con parámetros dados del dibujo) utilizando ImageCollection y 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();
}
Aquí hay un ejemplo que muestra como convertir documento PDF a file TIFF (en resolución necesaria y con parámetros dados del dibujo) utilizando PDFDocument y 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();
}
¿Cómo convertir TIFF a PDF?Aquí hay un ejemplo que muestra como convertir file TIFF a documento PDF por medio de ImageCollection y 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();
}
Aquí hay un ejemplo que muestra como convertir file TIFF a documento PDF utilizando PDFDocument y 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();
}
¿Cómo convertir TIFF a PDF/A?Aquí hay un ejemplo que muestra como convertir file TIFF a documento PDF/A utilizando ImageCollection y 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();
}
Aquí hay un ejemplo que muestra como convertir file TIFF a documento PDF/A utilizando PDFDocument y 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();
}
¿Cómo extracto el texto de página PDF?Esto es el ejemplo:
[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;
}
¿Cómo busqueda el texto sobre página PDF?Esto es el ejemplo:
[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);
}
¿Cómo encontrar y destacar el texto en documento PDF?Esto es el ejemplo:
[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
|